coloso / symfony-docker

This is a lightweight stack based on Alpine Linux for running Symfony 6 into Docker containers using docker compose.
100 stars 46 forks source link

Make:Migration throws exception: could not find driver #17

Closed Aloxen closed 1 year ago

Aloxen commented 1 year ago

Hey, I installed the security bundle, doctrine, maker and annotations to make a user system. After that I ran symfony console make:user and created the standard user (yes to everything). After that, I am supposed to create a magration with symfony console make:migration but it returns an exception. I have recently reset my linux, so that could be a reason why that happens, but I am not sure at all.

This is the exception: ` [critical] Error thrown while running command "make:migration". Message: "An exception occurred in the driver: could not find driver"

In ExceptionConverter.php line 87:

An exception occurred in the driver: could not find driver

In Exception.php line 28:

could not find driver

In Driver.php line 35:

could not find driver

make:migration

2023-09-22T14:00:01+02:00 [info] User Deprecated: Method "Symfony\Component\HttpKernel\Bundle\Bundle::build()" might add "void" as a native return type declaration in the future. Do the same in child class "Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle" now to avoid errors or add an explicit @return annotation to suppress this message. `

Does anyone know what I need to configure?

coloso commented 1 year ago

As far i know doctrine-migrations is not compatible with MongoDB ODM (it only supports DBAL). For MongoDB you could use this: https://github.com/doesntmattr/mongodb-migrations (but i've never tried before)

Aloxen commented 1 year ago

It setup a postgres database

Aloxen commented 1 year ago

version: '3'

services:

> doctrine/doctrine-bundle

database: image: postgres:${POSTGRES_VERSION:-15}-alpine environment: POSTGRES_DB: ${POSTGRES_DB:-app}

You should definitely change the password in production

  POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-!ChangeMe!}
  POSTGRES_USER: ${POSTGRES_USER:-app}
volumes:
  - database_data:/var/lib/postgresql/data:rw
  # You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
  # - ./docker/db/data:/var/lib/postgresql/data:rw

< doctrine/doctrine-bundle

volumes:

> doctrine/doctrine-bundle

database_data:

< doctrine/doctrine-bundle

This is my docker-compose.yml

> symfony/framework-bundle

APP_ENV=dev APP_SECRET=06bdab0ca09208aff2fe982e0b99181c

< symfony/framework-bundle

> doctrine/doctrine-bundle

DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=15&charset=utf8"

< doctrine/doctrine-bundle

and this my .env file

I am not a professional but everything looks like it is setup for postgres. I have always worked with mariadb but now that security set it up that way I thought why not try postgres

coloso commented 1 year ago

try to install in your php container the driver for postgres

Aloxen commented 1 year ago

I am kinda a newbie, can you explain it more detailed?

coloso commented 1 year ago

in the PHP Dockerfile remove mongodb-stable and add in the line where docker-php-ext-install pgsql pdo pdo_pgsql instead. Rebuild the php container.

Aloxen commented 1 year ago

Is that PHP Dockerfile in my projectfolder because curently I am not running any php container via docker

Aloxen commented 1 year ago

I did some digging and many people have the problem because the PDO drivers, but I checked and I have them installed on my system. I also checked if the db is up and I can talk to it via the integrated tool of php storm. What does doctrine need, that I haven't installed yet?