在Heroku上部署Symfony2应用程序

时间:2014-11-07 23:21:15

标签: php symfony heroku deployment

我正在尝试在heroku上部署symfony2应用程序并且我一直收到此错误:

-----> PHP app detected
-----> Resolved composer.lock requirement for PHP >=5.3.3 to version 5.6.2.
-----> Installing system packages...
       - PHP 5.6.2
       - Apache 2.4.10
       - Nginx 1.6.0
-----> Installing PHP extensions...
       - zend-opcache (automatic; bundled, using 'ext-zend-opcache.ini')
-----> Installing dependencies...
       Composer version 1.0-dev (ffffab37a294f3383c812d0329623f0a4ba45387) 2014-11-05 06:04:18
       Loading composer repositories with package information
       Installing dependencies from lock file
       Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
         - Installing doctrine/lexer (v1.0)
           Downloading: connection...    Downloading: 0%               Downloading: 80%    Downloading: 100%

     - Installing doctrine/annotations (v1.2.1)
       Downloading: connection...    Downloading: 0%               Downloading: 10%    Downloading: 15%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 55%    Downloading: 65%    Downloading: 70%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%

     - Installing doctrine/cache (v1.3.1)
       Downloading: connection...    Downloading: 0%               Downloading: 20%    Downloading: 25%    Downloading: 40%    Downloading: 45%    Downloading: 65%    Downloading: 90%    Downloading: 95%    Downloading: 100%

     - Installing doctrine/inflector (v1.0)
       Downloading: connection...    Downloading: 0%               Downloading: 55%    Downloading: 100%

     - Installing doctrine/collections (v1.2)
       Downloading: connection...    Downloading: 0%               Downloading: 35%    Downloading: 70%    Downloading: 100%

     - Installing doctrine/common (v2.4.2)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%

     - Installing doctrine/data-fixtures (dev-master ac36ccc)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 100%

     - Installing twig/twig (v1.16.2)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%    Downloading: 100%

     - Installing psr/log (1.0.0)
       Downloading: connection...    Downloading: 0%               Downloading: 15%    Downloading: 30%    Downloading: 45%    Downloading: 60%    Downloading: 75%    Downloading: 100%

     - Installing symfony/symfony (v2.5.6)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%    Downloading: 100%

     - Installing jdorn/sql-formatter (v1.2.17)
       Downloading: connection...    Downloading: 0%               Downloading: 10%    Downloading: 35%    Downloading: 45%    Downloading: 80%    Downloading: 95%    Downloading: 100%

     - Installing doctrine/dbal (v2.4.3)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%    Downloading: 100%

     - Installing doctrine/doctrine-bundle (v1.2.0)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 100%

     - Installing doctrine/doctrine-fixtures-bundle (dev-master 9a5b528)
       Downloading: connection...    Downloading: 0%               Downloading: 15%    Downloading: 30%    Downloading: 100%

     - Installing doctrine/orm (v2.4.6)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%    Downloading: 100%

     - Installing incenteev/composer-parameter-handler (v2.1.0)
       Downloading: connection...    Downloading: 0%               Downloading: 25%    Downloading: 50%    Downloading: 75%    Downloading: 100%

     - Installing knplabs/knp-components (1.3.1)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 100%

     - Installing knplabs/knp-paginator-bundle (2.4.1)
       Downloading: connection...    Downloading: 0%               Downloading: 20%    Downloading: 40%    Downloading: 60%    Downloading: 80%    Downloading: 100%

     - Installing knplabs/knp-snappy (0.2.1)
       Downloading: connection...    Downloading: 0%               Downloading: 35%    Downloading: 70%    Downloading: 100%

     - Installing knplabs/knp-snappy-bundle (dev-master 4e5a2cf)
       Downloading: connection...    Downloading: 0%               Downloading: 60%    Downloading: 95%    Downloading: 100%

     - Installing sensiolabs/security-checker (v2.0.0)
       Downloading: connection...    Downloading: 0%               Downloading: 90%    Downloading: 100%

     - Installing sensio/distribution-bundle (v3.0.8)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 95%    Downloading: 100%

     - Installing sensio/framework-extra-bundle (v3.0.2)
       Downloading: connection...    Downloading: 0%               Downloading: 15%    Downloading: 30%    Downloading: 40%    Downloading: 45%    Downloading: 55%    Downloading: 60%    Downloading: 70%    Downloading: 75%    Downloading: 85%    Downloading: 90%    Downloading: 100%

     - Installing kriswallsmith/assetic (v1.2.0)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%

     - Installing symfony/assetic-bundle (v2.5.0)
       Downloading: connection...    Downloading: 0%               Downloading: 10%    Downloading: 20%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 70%    Downloading: 80%    Downloading: 90%    Downloading: 100%

     - Installing monolog/monolog (1.11.0)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%    Downloading: 100%

     - Installing symfony/monolog-bundle (v2.6.1)
       Downloading: connection...    Downloading: 0%               Downloading: 15%    Downloading: 40%    Downloading: 55%    Downloading: 70%    Downloading: 85%    Downloading: 100%

     - Installing swiftmailer/swiftmailer (v5.3.0)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 10%    Downloading: 15%    Downloading: 20%    Downloading: 25%    Downloading: 30%    Downloading: 35%    Downloading: 40%    Downloading: 45%    Downloading: 50%    Downloading: 55%    Downloading: 60%    Downloading: 65%    Downloading: 70%    Downloading: 75%    Downloading: 80%    Downloading: 85%    Downloading: 90%    Downloading: 95%    Downloading: 100%    Downloading: 100%

     - Installing symfony/swiftmailer-bundle (v2.3.7)
       Downloading: connection...    Downloading: 0%               Downloading: 5%    Downloading: 25%    Downloading: 30%    Downloading: 55%    Downloading: 60%    Downloading: 85%    Downloading: 90%    Downloading: 100%

     - Installing twig/extensions (v1.2.0)
       Downloading: connection...    Downloading: 0%               Downloading: 10%    Downloading: 20%    Downloading: 30%    Downloading: 75%    Downloading: 100%

   Generating optimized autoload files
   Creating the "app/config/parameters.yml" file
   PHP Fatal error:  Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /tmp/build_634a4dfca497b3cefc3e87e3c0f3c462/app/AppKernel.php on line 30
   Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception

[RuntimeException的]
  执行“'cache:clear --no-warmup'”命令时发生错误。

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom -installers] [ - no-scripts] [ - no-progress] [-v | vv | vvv | --verbose] [-o | --optimize-autoloader] [--ignore-platform-reqs] [packages1 ] ... [packagesN]

!推送被拒绝,无法编译PHP应用程序enter code here

2 个答案:

答案 0 :(得分:3)

Heroku在推送时运行composer install --no-dev,因此不会安装任何开发包。

这意味着sensio/generator-bundle必须列在require中,而不是require-devcomposer.jsoncomposer update之后composer.lock再次生成AppKernel.php同时也提交两个)。

还要确保在if()中捆绑包在{{1}}块之外注册,该块仅在dev和test envs中运行。

答案 1 :(得分:2)

dev&之间存在混淆prod模式。 Composer以prod模式运行(例如--no-dev),但您的应用尝试以dev模式运行。

在Heroku中设置ENV var:

SYMFONY_ENV=prod