Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

symfony

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:[email protected]: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?

like image 373
Cláudio Ribeiro Avatar asked Nov 11 '17 17:11

Cláudio Ribeiro


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

like image 165
Benoit Galati Avatar answered Nov 10 '22 08:11

Benoit Galati