无法将symfony应用程序部署到Heroku

无法将symfony应用程序部署到Heroku,symfony,heroku,Symfony,Heroku,首先,很抱歉问了这么愚蠢的问题,但我对Heroku和Symfony都是新手。我正在学习Symfony,现在正试图将我的应用程序部署到Heroku。但在推到heroku之后,我遇到了无法解决的错误。我寻找答案,但没有找到答案。我的环境切换到PROD。这里有一堆我认为可以用来分析的文件 Initializing repository, done. Counting objects: 8783, done. Delta compression using up to 3 threads. Co

首先,很抱歉问了这么愚蠢的问题,但我对Heroku和Symfony都是新手。我正在学习Symfony,现在正试图将我的应用程序部署到Heroku。但在推到heroku之后,我遇到了无法解决的错误。我寻找答案,但没有找到答案。我的环境切换到PROD。这里有一堆我认为可以用来分析的文件

    Initializing repository, done.
Counting objects: 8783, done.
Delta compression using up to 3 threads.
Compressing objects: 100% (7959/7959), done.
Writing objects: 100% (8783/8783), 6.34 MiB | 499.00 KiB/s, done.
Total 8783 (delta 2737), reused 0 (delta 0)

-----> 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 (a309e1d89ded6919935a842faeaed8e888fbfe37) 2014-10-20 19:16:14

 !     WARNING: You have put Composer's vendor directory under version control.
       That directory should not be in your Git repository; only composer.json
       and composer.lock should be added, with Composer handling installation.
       Please 'git rm --cached vendor/' to remove the folder from your index,
       then add '/vendor/' to your '.gitignore' list to remove this notice.
       For more information, refer to the Composer FAQ: http://bit.ly/1rlCSZU

       Loading composer repositories with package information
       Installing dependencies from lock file
         - Removing sensio/generator-bundle (v2.4.0)
       Generating optimized autoload files
       Updating the "app/config/parameters.yml" file
       PHP Fatal error:  Class 'Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle' not found in /tmp/build_a721f054a4c0177a8e4e060c5b747b1c/app/AppKernel.php on line 26
       Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception



  [RuntimeException]                                                         
  An error occurred when executing the "'cache:clear --no-warmup'" command.  



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]



 !     Push rejected, failed to compile PHP app
以下是composer.json内容:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/", "SymfonyStandard": "app/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.5.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "~1.2",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~3.0",
        "sensio/framework-extra-bundle": "~3.0",
        "incenteev/composer-parameter-handler": "~2.0",
        "sensio/generator-bundle": "~2.4"
    },
    "require-dev": {
    },
    "scripts": {
        "post-root-package-install": [
            "SymfonyStandard\\Composer::hookRootPackageInstall"
        ],
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.5-dev"
        }
    }
}
和AppKernel.php内容:

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new Irishdash\StorageBundle\IrishdashStorageBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
    }
}

首先,请按照Heroku在警告中收到的说明进行操作

请使用“git rm--cached vendor/”从索引中删除该文件夹, 然后将“/vendor/”添加到您的“.gitignore”

然后将.gitignore文件的更改提交给Git

接下来,它将从锁文件安装依赖项,但看起来您已经将
sensio/generator捆绑包
require dev
移动到
require


有鉴于此,请尝试运行
php composer.phar update
,然后将
composer.lock
文件的更改提交到Git。

此外,您可能需要在应用程序中使用composer.lock文件

您想在按下之前运行
heroku config:set SYMFONY_ENV=prod
,否则,
post-install cmd
脚本将在
dev
环境中运行,该环境需要生成器包,但该包不可用,因为Heroku在推送过程中(使用Composer的
--无开发
模式)仅从
require
安装包,而不是从
require-dev
安装包,
$bundles[]=new Sensio\Bundle\DistributionBundle\sensiiodistributionbundle()
$bundles[]=new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle()
两者都需要位于
AppKernel.php
中的常规
$bundles
数组中。