Search code examples
phpdockersymfonydocker-composesymfony5

Symfony run fails on docker installation


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
!!  Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#76
!!    #message: """
!!      Attempted to load class "MakerBundle" from namespace "Symfony\Bundle\MakerBundle".\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 "Symfony\Bundle\MakerBundle\MakerBundle" 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.


Solution

  • I understood the reason. The reason because APP_ENV variable had value 'dev' in test environment and hence the system was trying to use MakerBundle. I updated the value with 'test' and now it is working as expected.