-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected
6.4.21
Description
Using an env variable in an abstract service and not having an implementation of that service will result in an exception. But only on prod
, it will work fine on dev
and stage
.
How to reproduce
Define an abstract service like shown below. Do not implement this service anywhere (parent: app.command.import
).
services:
app.command.import:
class: App\Bundle\MigrationBundle\Command\ImportCommand
abstract: true
arguments:
$dockerServiceName: '%env(DOCKER_SERVICE_NAME)%'
Run:
APP_ENV=prod bin/console cache:clear
// Clearing the cache for the prod environment with debug false
In PhpDumper.php line 418:
Environment variables "DOCKER_SERVICE_NAME" are never used. Please, check your container's configuration.
It will not happen with:
APP_ENV=stage bin/console cache:clear
APP_ENV=dev bin/console cache:clear
Possible Solution
In my opinion it should not throw an exception for env variables in abstract services. I would like to offer such services that the user can choose to implement them or not.
If this is not an option it should defenitely throw the same error in dev or stage. I should be notified of this issue before I deploy to production.
Additional Context
The reason it does not happen in dev or stage is the ContainerBuilderDebugDumpPass
. It dumps the entire container which marks every env variable as used.