Symfony stops with Class DebugBundle not found after a production install
Your error
Uncaught Error: Class "Symfony\Bundle\DebugBundle\DebugBundle" not found1 more line it can showFix it fast
Most common cause, 1 of 3Composer's post-install scripts run in dev during composer install --no-dev
Export APP_ENV=prod in the same shell before running Composer, so the scripts boot the prod environment, which does not load dev-only bundles.
export APP_ENV=prod
composer install --no-dev --optimize-autoloaderShort answer
Uncaught Error: Class "Symfony\Bundle\DebugBundle\DebugBundle" not found means Symfony 7.4 or 8.1 booted in the dev environment, where config/bundles.php enables DebugBundle, on a machine where composer install --no-dev skipped that package. Export APP_ENV=prod before Composer, set APP_ENV=prod for the web server, or install symfony/debug-bundle where dev mode is intended.
Which cause do you have?
Find out which environment Symfony boots in and whether the bundle's package is installed. A dev environment with the package missing is the whole story; the only question is where the dev value comes from.
grep -n "APP_ENV" .env .env.local 2>/dev/null
printenv APP_ENV
grep -n "DebugBundle" config/bundles.php
composer show symfony/debug-bundleThen find the line you see in this list and open its fix:
- 1Composer's post-install scripts run in dev during composer install --no-dev
The error appears in the output of composer install --no-dev, when the auto-scripts run cache:clear - 2The production server still runs with APP_ENV=dev
Composer succeeded, but the site or bin/console fails with the error, and APP_ENV is dev in .env with nothing overriding it - 3You want dev mode, but symfony/debug-bundle is not installed
A development machine or test box meant to run in dev, where composer show reports the package as not found
What does the error look like?
Uncaught Error: Class "Symfony\Bundle\DebugBundle\DebugBundle" not foundUncaught Error: Class "Symfony\Bundle\WebProfilerBundle\WebProfilerBundle" not found
Cause 1 of 3
Composer's post-install scripts run in dev during composer install --no-dev
You seeThe error appears in the output of composer install --no-dev, when the auto-scripts run cache:clear
Check
Class DebugBundle not found during composer install --no-dev means the post-install-cmd scripts booted the kernel in the dev environment. --no-dev keeps development packages such as symfony/debug-bundle out, while bundles.php still enables DebugBundle for dev. Symfony's deployment guide names this exact case: a class not found error during this step.
composer install --no-dev --optimize-autoloaderFix
Export APP_ENV=prod in the same shell before running Composer, so the scripts boot the prod environment, which does not load dev-only bundles.
export APP_ENV=prod
composer install --no-dev --optimize-autoloaderVerify
Composer finishes, including the cache:clear script, without the error.
APP_ENV=prod APP_DEBUG=0 php bin/console cache:clearConfirmed by symfony.com
Cause 2 of 3
The production server still runs with APP_ENV=dev
You seeComposer succeeded, but the site or bin/console fails with the error, and APP_ENV is dev in .env with nothing overriding it
Check
Class DebugBundle not found on a running site means the web server or the console boots Symfony with APP_ENV=dev, so bundles.php asks for a bundle that was never installed. APP_ENV comes from the .env files unless a real environment variable is set, and real environment variables always win over the files.
grep -n "APP_ENV" .env .env.local 2>/dev/null
APP_ENV=prod APP_DEBUG=0 php bin/console cache:clearFix
Set APP_ENV=prod as a real environment variable in the web server or PHP-FPM configuration, or put APP_ENV=prod in .env.local on that machine. Then clear the prod cache.
# .env.local on the production machine (not committed)
APP_ENV=prod
APP_DEBUG=0
APP_ENV=prod APP_DEBUG=0 php bin/console cache:clearVerify
The console runs without APP_ENV on the command line, and the site answers again.
php bin/console cache:clear
curl -I https://example.com/Confirmed by symfony.com
Cause 3 of 3
You want dev mode, but symfony/debug-bundle is not installed
You seeA development machine or test box meant to run in dev, where composer show reports the package as not found
Check
Class DebugBundle not found in a deliberate dev environment means the bundle is enabled in config/bundles.php but its package is not in vendor, for example after composer install --no-dev on that machine or after the package was removed from composer.json.
composer show symfony/debug-bundle
grep -n "debug-bundle" composer.jsonFix
Install the package as a development dependency, as the VarDumper docs instruct, or delete the DebugBundle line from config/bundles.php if you no longer want it.
composer require --dev symfony/debug-bundle
composer installVerify
composer show prints the package, and the dev site loads with dump() output in the toolbar.
composer show symfony/debug-bundleConfirmed by symfony.com
How do I stop it coming back?
- Put export APP_ENV=prod at the top of the deploy script, before composer install --no-dev.
- Set APP_ENV=prod as a real environment variable in the production PHP-FPM or web server config, not only in a .env file.
- Keep dev-only bundles marked ['dev' => true] in config/bundles.php, and their packages in require-dev.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Spotless Laundry, EZ Estimater.