Symfony composer install - Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException:试图加载类"SensioGeneratorBundle"

hou*_*fio 6 php symfony composer-php

Composer无法在生产环境中安装symfony.一切都在开发中运作良好.所有权限都没问题.

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 /home/ev/app/AppKernel.php:25
Stack trace:
#0 /home/ev/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(396): AppKernel->registerBundles()
#1 /home/ev/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(114): Symfony\Component\HttpKernel\Kernel->initializeBundles()
#2 /home/ev/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()
#3 /home/ev/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(118): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/ev/bin/console(27): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Inp in /home/ev/app/AppKernel.php on line 25
Run Code Online (Sandbox Code Playgroud)

这是AppKernel.php的第25行:

$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
Run Code Online (Sandbox Code Playgroud)

欢迎任何建议:)

小智 8

在Prod environnment中,不会注册SensioGeneratorBundle.该bundle应该像dev bundle一样定义如下:

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
        $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
        $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
        $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
        $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
    }
Run Code Online (Sandbox Code Playgroud)

在你的作曲家文件中:

"require-dev": {
    "sensio/generator-bundle": "~2.3"
}
Run Code Online (Sandbox Code Playgroud)

如果你想在Prod env中使用这个包中的生成命令,你应该将声明从dev移到Prod(不推荐!)