Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.5 "Class 'PDO' not found"

Here is the actual error when I open the site

enter image description here

Actually, I have successfully run php artisan migrate:refresh, and there is no error.

Already tried the following command.

php artisan cache:clear
php artisan config:clear

composer install
composer clearcache
composer dump-autoload
php artisan clear-compiled

I also checked if pdo is installed, thru php -m and its already installed

enter image description here

I'm using CentOS.

like image 653
lonestar Avatar asked Dec 08 '22 15:12

lonestar


2 Answers

What is most likely happening here is that the PDO module is enabled in the php-cli config (hence it works from command line), but is not enabled on the web server configuration file.

like image 82
Tudor Avatar answered Dec 11 '22 09:12

Tudor


I am adding all possible options which can solve the issue

Add use PDO; after your namespace or just before your class or at the top of your PHP file

As you are using centOS try the below commands

yum install php-pdo
yum install php-pdo_mysql

service httpd restart

If still its not solved check the php.ini file path to see which is being loaded in the phpinfo() output.

Sometimes there are two different PHP versions installed on a machine, one for CLI and one for the web server.

like image 44
Veerendra Avatar answered Dec 11 '22 10:12

Veerendra