The error "Class 'PDO' not found" means that the PHP Data Objects (PDO) extension is not enabled or installed on your server. PDO is required for database interactions in many PHP applications, including Laravel.
How to fix:
- Check if PDO is installed
Create a PHP file (e.g., info.php) with the following content and open it in your browser:
<?php
phpinfo();
Search for "PDO" on the page. If you don't see it, PDO is not installed or enabled.
- Enable or install PDO
-
On Ubuntu/Debian:
sudo apt-get install php-pdo sudo apt-get install php-mysql # For MySQL support sudo service apache2 restart # Or restart php-fpm/nginx as needed -
On CentOS/RHEL:
sudo yum install php-pdo sudo yum install php-mysql sudo systemctl restart httpd -
On Windows (XAMPP/WAMP):
- Open your
php.inifile. - Uncomment (remove
;from) these lines:extension=pdo_mysql extension=pdo_sqlite - Restart Apache.
- Open your
- Verify
Reload your application. The error should be gone if PDO is enabled.
Summary:
The error means the PDO extension is missing. Install and enable it for your PHP installation, then restart your web server.