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

时间:2014-10-29 20:21:02

标签: symfony heroku

起初,对不起愚蠢的问题,但我是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');
    }
}

3 个答案:

答案 0 :(得分:11)

您希望在推送之前运行heroku config:set SYMFONY_ENV=prod,否则post-install-cmd脚本将在dev环境中运行,该环境需要生成器捆绑包,但该版本不能仅作为Heroku使用在推送期间(使用Composer的require模式)从require-dev安装包,而不是从--no-dev安装包。

答案 1 :(得分:3)

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

  

请'git rm --cached vendor /'从索引中删除该文件夹,          然后将'/ vendor /'添加到'.gitignore'

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

接下来,它正在从锁定文件安装依赖项,但看起来您已将sensio/generator-bundle包从require移至require-dev

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

答案 2 :(得分:0)

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

相关问题