我用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
我理解的是供应商目录下缺少依赖关系,由于解决了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一起工作而不对供应商目录进行版本控制或以其他方式?提前谢谢。
答案 0 :(得分:1)
我通过使用composer install更新.travis.yml解决了这个问题。
language: php
php:
- '5.5'
- '5.6'
- '7.0'
- hhvm
- nightly
before_script: composer install