【问题标题】:Symfony + Travis-CI + Heroku + GitHub basic .gitignore and travis.yml?Symfony + Travis-CI + Heroku + GitHub 基本 .gitignore 和 travis.yml?
【发布时间】:2017-04-19 07:23:21
【问题描述】:

我使用 composer 命令创建了一个 Symfony 项目:“composer create-project symfony/framework-standard-edition my_project_name”,并使用 git 和 GitHub 作为远程托管将其置于版本控制之下。 此外,我需要使用 Travis-CI 进行持续集成和状态检查,以及使用 Heroku 进行部署。

作为我第一次使用 Symfony、travis 和 heroku,我在使用它们的配置文件时遇到了一些问题。

这是我的 .gitignore 文件:

/.idea
/app/config/parameters.yml
/build/
/phpunit.xml
/var/*
!/var/cache
/var/cache/*
!var/cache/.gitkeep
!/var/logs
/var/logs/*
!var/logs/.gitkeep
!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
!var/SymfonyRequirements.php
/vendor/
/web/bundles/

这是我的 .travis.yml 文件:

language: php
php:
  - '5.5'
  - '5.6'
  - '7.0'
  - hhvm
  - nightly

This is the log of travis-ci failing

我的理解是vendor目录下缺少依赖,由于解决heroku bild的错误信息,已经被git忽略了:

-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
       - php (7.1.0)
       - apache (2.4.20)
       - nginx (1.8.1)
-----> Installing dependencies...
       Composer version 1.2.2 2016-11-03 17:43:15
 !     WARNING: Your Composer vendor dir is part of your Git repository.
       This directory should not be under version control; only your
       'composer.json' and 'composer.lock' files should be added, which
       will let Composer handle installation of dependencies on deploy.
       To suppress this notice, first remove the folder from your index
       by running 'git rm -r --cached vendor/'.
       Next, edit your project's '.gitignore' file and add the folder
       '/vendor/' to the list.
       For more info, refer to the Composer FAQ: https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md
       Loading composer repositories with package information
       Installing dependencies from lock file
         - Removing symfony/phpunit-bridge (v3.1.7)
         - Removing sensio/generator-bundle (v3.1.1)
       Generating optimized autoload files
       > Incenteev\ParameterHandler\ScriptHandler::buildParameters
       Updating the "app/config/parameters.yml" file
       > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
       > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
       PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SensioGeneratorBundle" from namespace "Sensio\Bundle\GeneratorBundle".
       Did you forget a "use" statement for another namespace? in /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/app/AppKernel.php:25
       Stack trace:
       #0 /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(396): AppKernel->registerBundles()
       #1 /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(114): Symfony\Component\HttpKernel\Kernel->initializeBundles()
       #2 /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()
       #3 /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/vendor/symfony/symfony/src/Symfony/Component/Console/Appli in /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/app/AppKernel.php on line 25
       Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception


         [RuntimeException]                                                                                                                                                                                                                   
         An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                                                                                                            
         PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SensioGeneratorBundle" from namespace "Sensio\Bundle\GeneratorBundle".                                                 
         Did you forget a "use" statement for another namespace? in /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/app/AppKernel.php:25                                                                                   
         Stack trace:                                                                                                                                                                                                                         
         #0 /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(396): AppKernel->registerBundles()                                                          
         #1 /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(114): Symfony\Component\HttpKernel\Kernel->initializeBundles()                              
         #2 /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()                             
         #3 /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/vendor/symfony/symfony/src/Symfony/Component/Console/Appli in /tmp/build_3481ed5a9ce634e19d2af5d00bd7a3f9/izio7-YourTeam-8f31587/app/AppKernel.php on line 25  
         .                                                                                                                                                                                                                                    


       install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...

 !     Push rejected, failed to compile PHP app.
 !     Push failed

我可以做一些命令或更改,以使其与 travis-ci 和 heroku 一起工作,而无需对供应商目录进行版本控制或以其他方式?提前致谢。

【问题讨论】:

    标签: php heroku github symfony travis-ci


    【解决方案1】:

    我通过使用 composer install 更新 .travis.yml 解决了这个问题。

    language: php
    php:
      - '5.5'
      - '5.6'
      - '7.0'
      - hhvm
      - nightly
    
    before_script: composer install
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-31
      • 2015-03-28
      • 2018-03-14
      • 2020-02-06
      • 2013-12-02
      相关资源
      最近更新 更多