Symfony "Invalid env" - only "word" characters are allowed

Viewed 4775

I'm currently trying to get a Symfony project up and running. The problem is when I try to setup the database I keep getting

[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException] 
Invalid env(resolve:DATABASE_URL) name: only "word" characters are allowed.

I edited the .env file to have my local database credentials. The DATABASE_URL variable looks like the following:

DATABASE_URL="mysql://user:pass@192.168.10.10:3306/db_name?charset=utf8mb4&serverVersion=5.7"

Where of course, user, pass and db_name are the credentials.

Any idea on how to solve this problem?

1 Answers

I found something in doctrine recipe. It's likely because you are using symfony 3.3 with symfony/flex so you would need to remove the resolve keyword, ie. in your config/packages/doctrine.yaml :

doctrine:
    dbal:
        url: '%env(DATABASE_URL)%'

See this news for more information

Related