PHP致命错误:未捕获的Symfony \ Component \ Debug \ Exception \ ClassNotFoundException

问题描述 投票:0回答:1

我尝试在Amazon Web Service的Elastic Beanstalk上使用Symfony 4.0.6发布我的Web应用程序。但是,当应用程序部署时,我遇到了“脚本缓存:清除返回错误代码255 !!(Executor :: NonZeroExitStatus)”的问题

我更新了symfony / flex(v1.0.70 => v1.0.71),我已经检查了以下内容。

$ composer install --no-dev --optimize-autoloader
~~~~
  - Removing symfony/process (v4.0.6)
Generating optimized autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255
!!  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DebugBundle" from namespace "Symfony\Bundle\DebugBundle".
!!  Did you forget a "use" statement for another namespace? in C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\src\Kernel.php:32
!!  Stack trace:
!!  #0 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\http-kernel\Kernel.php(403): App\Kernel->registerBundles()
!!  #1 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\http-kernel\Kernel.php(122): Symfony\Component\HttpKernel\Kernel->initializeBundles()
!!  #2 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\framework-bundle\Console\Application.php(64): Symfony\Component\HttpKernel\Kernel->boot()
!!  #3 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\vendor\symfony\console\Application.php(143): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
!!  #4 C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\bin\console(39) in C:\Users\xsunt\PhpstormProjects\xsun\tv\4.0\src\Kernel.php on line 32

我认为我们需要检查以下三个捆绑包

class Kernel extends BaseKernel
{
    public function registerBundles()
    {
        $contents = require $this->getProjectDir().'/config/bundles.php';
        foreach ($contents as $class => $envs) {
            if (isset($envs['all']) || isset($envs[$this->environment])) {
                **yield new $class();**
            }
        }
}

cat /config/bundles.php

    Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true],
    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
    Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],

你能给我一个建议吗?

symfony debugging bundle
1个回答
0
投票

我认为问题是你没有传递APP_ENV环境变量,所以脚本cache:clear在开发模式下运行。

你应该运行APP_ENV=prod composer install --no-dev --optimize-autoloader

这也提到了https://symfony.com/doc/current/deployment.html#c-install-update-your-vendors

另一种选择是运行composer install --no-dev --optimize-autoloader --no-scripts,额外的标志不会执行任何脚本,但我不知道你的应用程序是否依赖脚本来运行。

© www.soinside.com 2019 - 2024. All rights reserved.