skip to Main Content

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


  1. in the .env key:value should be sth like this

    APP_ENV=dev # or APP_ENV="dev"
    APP_NAME=Demo
    DATABASE_URL=mysql://username:my_Pass@localhost:3306/DB_nameserverVersion=5.7
    

    php bin/console cache:clear
    and then restart the server

    Login or Signup to reply.
  2. 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) to dev and remove spaces.

    --env=dev
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search