'Symfony-docker build throws class not found error
This is a link to the full repository, in case you need all the files: https://github.com/tech0tron/civstock-symfony
When I run docker-compose build --pull --no-cache, it runs all the way to step 36 until it gives this error:
+ composer run-script post-install-cmd
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! PHP Fatal error: Uncaught Error: Class "Symfony\Bundle\TwigBundle\TwigBundle" not found in /srv/app/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php:131
!! Stack trace:
!! #0 /srv/app/vendor/symfony/http-kernel/Kernel.php(382): App\Kernel->registerBundles()
!! #1 /srv/app/vendor/symfony/http-kernel/Kernel.php(766): Symfony\Component\HttpKernel\Kernel->initializeBundles()
!! #2 /srv/app/vendor/symfony/http-kernel/Kernel.php(128): Symfony\Component\HttpKernel\Kernel->preBoot()
!! #3 /srv/app/vendor/symfony/framework-bundle/Console/Application.php(166): Symfony\Component\HttpKernel\Kernel->boot()
!! #4 /srv/app/vendor/symfony/framework-bundle/Console/Application.php(72): Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands()
!! #5 /srv/app/vendor/symfony/console/Application.php(171): Symfony\Bundle\FrameworkBundle\Console\Application->doRun()
!! #6 /srv/app/vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php(54): Symfony\Component\Console\Application->run()
!! #7 /srv/app/vendor/autoload_runtime.php(29): Symfony\Component\Runtime\Runner\Symfony\ConsoleApplicationRunner->run()
!! #8 /srv/app/bin/console(11): require_once('...')
!! #9 {main}
!! thrown in /srv/app/vendor/symfony/framework-bundle/Kernel/MicroKernelTrait.php on line 131
!!
Script @auto-scripts was called via post-install-cmd
The command '/bin/sh -c set -eux; mkdir -p var/cache var/log; composer install --prefer-dist --no-dev --no-progress --no-scripts --no-interaction; composer dump-autoload --classmap-authoritative --no-dev; composer symfony:dump-env prod; composer run-script post-install-cmd; chmod +x bin/console; sync' returned a non-zero code: 255
ERROR: Service 'php' failed to build : Build failed
My bundles.php file supposedly shows the TwigBundle class being registered:
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
];
What should I change to correct this?
Solution 1:[1]
I inspected the repository you provided. You are missing symfony/twig-bundle from your dependency list, and so it is not installed.
The reason it stops at step 36 is when you run composer symfony:dump-env prod you receive an error from Symfony when it tries to process your bundles.php and cannot lot the bundle.
You will need to require the correct bundle, and try again.
composer require symfony/twig-bundle
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | colonelclick |
