davy_yg's avatar

Class "PDO" not found

I get this error message:

Class "PDO" not found

Any clue why?

0 likes
2 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

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:

  1. 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.

  1. 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.ini file.
    • Uncomment (remove ; from) these lines:
      extension=pdo_mysql
      extension=pdo_sqlite
      
    • Restart Apache.
  1. 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.

Snapey's avatar

this must be your answer. Mark it solved.

Please or to participate in this conversation.