I’m encountering a strange problem on symfony 5.4 when executing every command , made by me or of the framework like cache:clear , i instantly recieve this error:
In Kernel.php line 418
The environment "= " contains invalid characters, it can only contain characters allowed in PHP class names.
Scenario:
Framework: Symfony 5.5
PHP version: 8.2
Architecture: MacOS M1
The program run inside a docker container on the local machine.
The problem show only when i run a symfony command, but if i call the normal symfony controllers via browser or postman, they are able to correctly access to the env variables , connect to external database e return correctly the data.
Can an error like this be the consequence of a crash of somekind ? and if yes how can debug that if now error exept che kernel exception show in the terminal or the logs.
Cant find a clue of this strange behaviour.
Tx for your help
I’ve tryed the following tests
- TEST1 rebuild the docker imager by docker-compose down,
docker-compose build docker-compose up - TEST2 rebuild on another
maching ( another Mac M1 ) - TEST3 try controller and they works
correctly event if they depends by the env variables to works like
access to a db and return datas. - TEST4 i created a controller that
print a system parameter depending from a env variable and make it
print parameter and is printed ok
2
Answers
in the
.env
key:value should be sth like thisphp bin/console cache:clear
and then restart the server
Probably you’re executing bin/console with
--env = .env.dev.local
flag.The environment name should be only
dev
, not.env.dev
.Change your
APP_ENV
variable (or your--env
flag) todev
and remove spaces.