部署 Symfony 4 应用程序但作曲家有 "cache:clear error"
Deploy Symfony 4 application but composer has "cache:clear error"
我尝试部署我的 Symfony 应用程序,当我使用 composer 安装依赖项时,出现错误。
我看到有人遇到同样的问题,但我没有找到解决方案。喜欢将 .env
APP_ENV=dev
更改为 APP_ENV=prod
.
这里是日志:
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 "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle".
!! Did you forget a "use" statement for another namespace? in /tmp/build.YZSXu7Ir2b/src/Kernel.php:23
我只在开发环境中使用 DoctrineFixturesBundle:
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.1",
"fzaninotto/faker": "^1.8",
"symfony/profiler-pack": "^1.0"
}
这是我的 config/bundles.php :
...
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
...
这里是 Kernel.php 的第 23 行:
...
public function registerBundles(): iterable
{
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
yield new $class(); // line 23
}
}
}
...
如果我理解你的问题,你只需 Composer Install,但最好是 composer install --no-dev -- optimize-autoloader 已解释Here。不然不知道
请检查目录 "vendor/doctrine/doctrine-fixtures-bundle" 是否存在以及里面是否有文件 - 特别是“vendor/doctrine/doctrine-fixtures-bundle/DoctrineFixturesBundle.php"
如果它们不存在,那么您似乎没有执行 "composer update" 来添加包。在这种情况下,请尝试:
COMPOSER_MEMORY_LIMIT=-1 composer update doctrine/doctrine-fixtures-bundle
您应该会看到如下内容:
- Installing doctrine/data-fixtures (v1.3.1): Loading from cache
- Installing doctrine/doctrine-fixtures-bundle (3.2.2): Loading from cache
我尝试部署我的 Symfony 应用程序,当我使用 composer 安装依赖项时,出现错误。
我看到有人遇到同样的问题,但我没有找到解决方案。喜欢将 .env
APP_ENV=dev
更改为 APP_ENV=prod
.
这里是日志:
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 "DoctrineFixturesBundle" from namespace "Doctrine\Bundle\FixturesBundle".
!! Did you forget a "use" statement for another namespace? in /tmp/build.YZSXu7Ir2b/src/Kernel.php:23
我只在开发环境中使用 DoctrineFixturesBundle:
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.1",
"fzaninotto/faker": "^1.8",
"symfony/profiler-pack": "^1.0"
}
这是我的 config/bundles.php :
...
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
...
这里是 Kernel.php 的第 23 行:
...
public function registerBundles(): iterable
{
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
yield new $class(); // line 23
}
}
}
...
如果我理解你的问题,你只需 Composer Install,但最好是 composer install --no-dev -- optimize-autoloader 已解释Here。不然不知道
请检查目录 "vendor/doctrine/doctrine-fixtures-bundle" 是否存在以及里面是否有文件 - 特别是“vendor/doctrine/doctrine-fixtures-bundle/DoctrineFixturesBundle.php"
如果它们不存在,那么您似乎没有执行 "composer update" 来添加包。在这种情况下,请尝试:
COMPOSER_MEMORY_LIMIT=-1 composer update doctrine/doctrine-fixtures-bundle
您应该会看到如下内容:
- Installing doctrine/data-fixtures (v1.3.1): Loading from cache
- Installing doctrine/doctrine-fixtures-bundle (3.2.2): Loading from cache