How to Fix could not find driver Error in Laravel 11 with PHP 8.3
When you set up a fresh Laravel 11 project on PHP 8.3 and try to run migrations or connect to the database, you might see this annoying error: PDOException::(“could not find driver”) This usually appears when you run commands like:
php artisan migrate
php artisan tinker
php artisan db
The good news is that nothing is wrong with Laravel itself. The problem is that your PHP installation is missing the required database driver extension, or it is not enabled.
In this guide, we will walk through step-by-step how to fix the could not find driver error for Laravel 11 with PHP 8.3 on different environments.
Why this error happens
Laravel uses PDO (PHP Data Objects) to connect to databases. Each database type needs its own driver:
- MySQL / MariaDB:
pdo_mysql - PostgreSQL:
pdo_pgsql - SQLite:
pdo_sqlite - SQL Server:
pdo_sqlsrv(on Windows)
If the driver extension is not enabled in PHP, PDO cannot talk to your database, and Laravel shows:
could not find driver
So the fix is simple in theory:
- Enable or install the correct PDO extension for your database.
- Make sure PHP is using that configuration (CLI and web server).
- Ensure your
.envsettings match the driver you installed.
Step 1: Check which database you are using in Laravel
Open your .env file in the root of your Laravel 11 project and look at your database settings:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
The important one is:
DB_CONNECTION=mysql
Common values:
mysqlpgsqlsqlitesqlsrv
Whatever is set here is the driver you must enable in PHP.
Step 2: Check enabled PDO extensions in PHP 8.3
Run this command in your terminal:
php -m | grep -i pdo
If you are using Windows PowerShell, you can use:
php -m | Select-String "pdo"
You should see something like:
PDO
pdo_mysql
If you only see PDO but not pdo_mysql (for MySQL) or pdo_pgsql (for PostgreSQL), then the specific driver is not enabled. That is why Laravel cannot find the driver.
Step 3: Fix on Windows (XAMPP, WAMP, Laragon)
If you are on Windows, the most common stack is XAMPP, WAMP, or Laragon.
3.1 Enable pdo_mysql in php.ini (for MySQL)
- Find the
php.inifile used by your CLI:php --iniThis shows the path toLoaded Configuration File. - Open that
php.iniin a text editor (Notepad, VS Code, etc.). - Search for these lines:
;extension=pdo_mysql ;extension=mysqli - Remove the semicolon at the beginning so they become:
extension=pdo_mysql extension=mysqli - Save the file.
- Restart Apache (or Nginx) from your control panel (XAMPP, WAMP, Laragon).
- Close and reopen your terminal, then run:
php -m | grep -i pdoThis time you should seepdo_mysqlin the list.
3.2 Make sure PHP used by Laravel is the same as XAMPP/WAMP
Sometimes your system has multiple PHP versions installed, and the one in your PATH is not the same as XAMPP/WAMP PHP.
Run:
php -v
Check if the path looks like C:\xampp\php\php.exe or similar. If not, you may need to add the correct PHP folder to your system PATH, or call it with the full path, for example:
"C:\xampp\php\php.exe" artisan migrate
Step 4: Fix on Linux (Ubuntu, Debian, etc.)
On Linux with PHP 8.3, you need to install the matching extension packages.
4.1 Install PDO driver for MySQL
For MySQL:
sudo apt update
sudo apt install php8.3-mysql
For PostgreSQL:
sudo apt install php8.3-pgsql
For SQLite, it is usually built in, but if not:
sudo apt install php8.3-sqlite3
After installing, restart your web server and PHP-FPM (if used):
sudo systemctl restart apache2
# or
sudo systemctl restart nginx
sudo systemctl restart php8.3-fpm
Then check:
php -m | grep -i pdo
You should now see pdo_mysql or pdo_pgsql in the list.
Step 5: Fix on macOS (Homebrew PHP)
If you are using Homebrew PHP on macOS:
- Check your PHP version:
php -v - For MySQL, install the extension if needed or link it properly. Often with recent PHP versions, PDO MySQL is already included. Make sure your PHP is the one from Homebrew:
which phpIt should be something like/opt/homebrew/bin/phpor/usr/local/bin/php. - If you are using Valet, run:
valet restart - Again, verify:
php -m | grep -i pdo
Step 6: Make sure your .env matches the installed driver
If you installed pdo_mysql, then in .env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_user
DB_PASSWORD=your_password
If you installed pdo_pgsql, then:
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=your_database
DB_USERNAME=your_user
DB_PASSWORD=your_password
For SQLite:
DB_CONNECTION=sqlite
DB_DATABASE=/full/path/to/database.sqlite
After editing .env, clear the config cache:
php artisan config:clear
php artisan config:cache
Step 7: Test the connection again
Now test your setup:
php artisan migrate
If everything is configured correctly, migrations should run without the could not find driver error.
You can also test quickly using Tinker:
php artisan tinker
>>> DB::connection()->getPdo();
If no error appears, your driver is working.
Example: Full mini checklist
Here is a quick checklist to fix could not find driver in Laravel 11 with PHP 8.3:
- Check database driver in
.env:DB_CONNECTION=mysqlorpgsqlorsqliteorsqlsrv.
- Confirm installed PHP modules:
php -m | grep -i pdo - If missing:
- On Windows: enable
extension=pdo_mysql(or others) inphp.ini. - On Linux: install
php8.3-mysql,php8.3-pgsql, orphp8.3-sqlite3. - On macOS: ensure you use the correct PHP binary with PDO enabled.
- On Windows: enable
- Restart web server and PHP-FPM (if used).
- Clear Laravel config cache:
php artisan config:clear php artisan config:cache - Run:
php artisan migrate
Conclusion
The could not find driver error in Laravel 11 with PHP 8.3 is almost always caused by a missing or disabled PDO extension for your chosen database. Once you enable or install the correct driver and make sure Laravel is pointing to the right database and PHP installation, the error disappears.