I get the following error when I try to run my Symfony project via docker compose. Here is the error:
Script cache:clear returned with error code 255
!! SymfonyComponentErrorHandlerErrorClassNotFoundError {#76
!! #message: """
!! Attempted to load class "MakerBundle" from namespace "SymfonyBundleMakerBundle".n
!! Did you forget a "use" statement for another namespace?
!! """
!! #code: 0
!! #file: "./vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php"
!! #line: 132
!! trace: {
!! ./vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:132 { …}
!! ./vendor/symfony/http-kernel/Kernel.php:386 { …}
!! ./vendor/symfony/http-kernel/Kernel.php:788 { …}
!! ./vendor/symfony/http-kernel/Kernel.php:128 { …}
!! ./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
!! ./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
!! ./vendor/symfony/console/Application.php:171 { …}
!! ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …}
!! ./vendor/autoload_runtime.php:35 { …}
!! ./bin/console:11 {
!! ›
!! › require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
!! ›
!! arguments: {
!! "/var/www/html/vendor/autoload_runtime.php"
!! }
!! }
!! }
!! }
!! 2023-11-17T17:16:04+03:00 [critical] Uncaught Error: Class "SymfonyBundleMakerBundleMakerBundle" not found
The problem is that, makerbundle should not be in non-dev environments. When I remove it from composer.json file it works as expected but otherwise it cause the problem. What am I supposed to do now? Thanks for the advices.
2
Answers
1 – Install MakerBundle: "Check if MakerBundle is installed with composer require symfony/maker-bundle –dev. This installs it for development use."
2 – Bundle Configuration: "Ensure MakerBundle is configured in bundles.php as SymfonyBundleMakerBundleMakerBundle::class => [‘dev’ => true], for development environment loading."
3 – Clear Cache Manually: "Try clearing the cache manually by deleting var/cache directories, then rerun the command."
Don’t execute that script in the environment it is not for. And instead, only execute it in the environment it is for.
Control script and plugin execution with the appropriate command line flags of Composer, look them up in the manual of the Composer version you have in use (e.g.
--no-plugins
&--no-scripts
, but this can change across composer versions and commands).Better yet, do not have them in the environments they are not needed for, then they can’t be executed. Cf. Adrian98dos’ answer.
Only ever use the right tool with the right configuration for the job, otherwise expect things to break and equip yourself with the mindset necessary to start reading late. These things are all documented.