4
votes

im working with symfony and when i type in console this:

php app/console doctrine:schema:create

i have the next errors

[Doctrine\DBAL\Exception\DriverException]
An exception occured in driver: could not find driver

[Doctrine\DBAL\Driver\PDOException]
could not find driver

[PDOException]
could not find driver

I've been following this link in order to sort it out

PDOException “could not find driver” in php

this is what i get when i run php -m

root@asus-K53SD:/opt/lampp/htdocs/symfonycurso# php -m

root@asus-K53SD:/opt/lampp/htdocs/symfonycurso# php -m
[PHP Modules]
calendar
Core
ctype
date
dom
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib
Zend Modules
Zend OPcache

i uncommented this and restart the server

extension=php_pdo_pgsql.dll

this is my parameter.yml

Added database_driver : pdo_mysql and password removed (before was null)

 # This file is auto-generated during the composer install
parameters:
    database_driver  : pdo_mysql
    database_host: 127.0.0.1
    database_port: 
    database_name: blog
    database_user: root
    database_password: 
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: 
    mailer_password: 
    secret: ThisTokenIsNotSoSecretChangeIt

anyone know how can i fix this errors?? can be the problem that im working on PHP7

NOTE: Using lampp on linux

3
Your Symfony parameters.yml says you're using pdo_mysql, so there's no need to load pdo_pgsql (this is PostgreSQL)... load pdo_mysql in php.ini and you're set. - ccKep
@ccKep I added the line database_driver : pdo_mysql because i saw it in other post. when you say " to load pdo_mysql in php.ini" you mean to add ... extension=php_pdo_mysql.dll extension=pdo_mysql.dll in the php.ini file ... i tried too. restarted lampp and delete var/cache (symfony) in my phpinfo i can see API Extensions mysqli,pdo_mysql - Zenit
NOTE: Using lampp on linux, why would you add .dll files to your extension list in php.ini on a linux device? Also: If phpinfo() actually says PDO and pdo_mysql are loaded, what's the new error message from symfony? - ccKep
@ccKep im just following the steps of others post with similar problem. I have no experience dealing with extension in lampp. Nevertheless.. i would say that phpinfo() have always said that pdo_mysql is enable. The thing is that many post point out that the problem is... because a line has to be uncomment or added.... None of them worked out to me - Zenit

3 Answers

7
votes

Using LAMP you don't need to enable php_pdo_mysql.dll in the .ini file. Instead, run this below command in cli,

sudo apt-get install php7.0-mysql (Use specific PHP version which you used).

Now you can see pdo_mysql module by running php -m command.

Then, you clear the cache in symfony and run the symfony commands.

0
votes

Check your php version and versions your modules for php. I had problem after php update from 7.0 to 7.1. PHP migrate should help you. For exmaple http://php.net/manual/en/migration71.php

0
votes

It generally happens when symfony does not find the driver to connect to mysql. for me i had no mysql driver installed so i did following in my terminal :

// I have php version 7.2 
sudo apt-get install php7.2-mysql to install the mysql 

then i ran following in my terminal to create database

php bin/console doctrine:database:create

which worked perfectly. I hope this does help to some one having similar problem