PDOException "could not find driver" in PHP
When attempting to create a schema with the Symfony2 command:
php app/console doctrine:schema:create
You may encounter the error message:
PDOException “could not find driver”
Despite uncommenting the line extension=php_pdo_mysql.dll in the php.ini file, the issue persists. Additionally, running php -m yields the following warnings:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
Solution:
For Ubuntu systems, execute the following command in the console:
sudo apt-get install php5-gd php5-mysql
This command will install the necessary PHP modules, and the issue should be resolved.
The above is the detailed content of How to Fix \"PDOException: could not find driver\" in Symfony2?. For more information, please follow other related articles on the PHP Chinese website!