Xavier
Xavier

Reputation: 23

DB create Doctrine2

I'm new to the Symfony and Doctrine world.

So i'm following the doc to install Symfony. All went well.

Next Step : create the DB. Again I'm following the documentation (Databases and the Doctrine ORM) and run the command php bin/console doctrine:database:create

This command give me no output and is running for more than 30 minuts which seems to be a lot just to create a DB.

I've got a local mysql server running on 127.0.0.1:3000

here is my .env file

   ###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# For a PostgreSQL database, use: "postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8"
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
DATABASE_URL=mysql://root:[email protected]:3000/my_project?serverVersion=8.0.19
###< doctrine/doctrine-bundle ###

Does anyone have a clue why this command does not give me any output ?

Upvotes: 0

Views: 227

Answers (1)

Xavier
Xavier

Reputation: 23

Problem solved even if I don't understand why.

I edit the doctrine.yaml that was like

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

to

doctrine:
dbal:
    default_connection: default
    connections:
        default:
            dbname:         my_project
            user:           root
            password:       root
            host:           localhost
            driver:         pdo_mysql
            server_version: '8.0.19' # your database server version here
    #url: '%env(resolve:DATABASE_URL)%'

Upvotes: 1

Related Questions