I'm using symfony 5, everything works fine when I do a command line migration (ex: php bin/console make:migration
), but when I try to save a form in code with $doctrine->flush();
I get an error "An exception occurred in the driver: could not find driver"
I'm using mysql
,
my config:
in my .env
file i have :
DATABASE_URL="mysql://root:@127.0.0.1:3306/myecom?serverVersion=10.4.11-MariaDB"
my doctrine.yaml
:
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
url: '%env(resolve:DATABASE_URL)%'
my controller:
$doctrine = $this->getDoctrine()->getManager();
$doctrine->persist($user);
$doctrine->flush();
Do you have any hint to debug this?
EDIT : Resolved
The problem is that the php version of apache (php 7.2) is not supported by doctrine which requires php > 7.3, I put apache on php 7.3 and it works, to do it I proceeded as follows:
Disable the current php version:
sudo a2dismod php7.2
Restart apache:
systemctl restart apache2
Enable php 7.3:
sudo a2enmod php7.3
Restart Symfony server:
php bin/console server:stop
php bin/console server:start