我尝试在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],
你能给我一个建议吗?
答案 0 :(得分: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
,带有额外的标志将不执行脚本,但是我不知道您的应用程序是否依赖于要运行的脚本。