Symfony "You have requested a non-existent service" in CI
The Symfony service container was asked for a service id it does not define. The id is wrong, the service was removed or made private, or the bundle that registers it is not loaded in the environment CI runs (often the test env).
What this error means
A command or test fails during container compilation with "You have requested a non-existent service \"X\"." The id in the message is the one the container cannot resolve.
In ContainerBuilder.php line 1075:
You have requested a non-existent service "app.mailer". Did you mean this: "mailer.mailer"?Common causes
The service id is misspelled or was removed
A reference in a controller, config, or another service points at an id the container never defines. The "Did you mean" hint lists the closest real ids.
The bundle is not enabled in the CI environment
Symfony loads bundles per environment in config/bundles.php. If a bundle is only enabled for dev and CI runs with APP_ENV=test, its services are absent.
How to fix it
List the real service ids and correct the reference
- Run
bin/console debug:containerwith the sameAPP_ENVCI uses to see defined ids. - Fix the reference to match a real id, or make the service public if it is fetched from the container directly.
- Re-run the failing command to confirm the id resolves.
APP_ENV=test php bin/console debug:container app.mailerEnable the bundle for the test environment
Add the environment to the bundle entry in config/bundles.php so its services register when CI compiles the container.
// config/bundles.php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
App\SomeBundle\SomeBundle::class => ['all' => true],
];How to prevent it
- Run
debug:containerwithAPP_ENV=testlocally so missing ids surface before CI. - Keep bundle environment maps in
config/bundles.phpconsistent with what tests need. - Prefer autowired constructor injection over fetching services by id from the container.