Reputation: 57786
I am using Laravel with HHVM.
MySQL is working in normal controller functions.
But whenever from Commands (artisan), DB connection of MySQL (PDO) is initialised, then error comes of "could not find driver".
Also I have tried writing connection initialisation from Controller function and calling it from Command still same error comes.
$conn = new \PDO("mysql:host=$servername;dbname=$db_name", $username, $password);
Upvotes: 1
Views: 404
Reputation: 801
I think you have not installed php-mysql driver
Try installing by using following command
sudo apt-get install php5 php5-mysql
Upvotes: 2
Reputation: 6676
Make sure the PDO mysql driver is enabled.
If you're running debian/ubuntu, you can check like this
$ php -i | grep pdo
/etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini, # <-- This line
pdo_mysql
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
And if it's not enabled, you can enable it with:
$ php5enmod pdo_mysql
For other operating systems, you'll have to check the documentation.
Don't forget to restart your web server (Apache, or other).
Upvotes: 0