artisan migration error "Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found",

artisan migration error "Class 'Doctrine\\DBAL\\Driver\\PDOMySql\\Driver' not found",

  1. Blog
  2. 15 November 2026
  3. 2 min read

Stefan Bogdanescu

Founder & Senior Architect

Artisan migration error "Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found"

Encountering the exception Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found during an Artisan migration run typically signals a version mismatch between the Laravel framework and the Doctrine DBAL library. This specific error usually manifests when the application is running on a version of Laravel that expects Doctrine DBAL 2, but the installed instance is actually Doctrine DBAL 3 or higher.

The root cause lies in how the doctrine/dbal package evolved. In Doctrine DBAL 2, the driver interface and implementation classes were structured to include the PDOMySql\Driver class. However, Doctrine DBAL 3 introduced a significant breaking change regarding the architecture of database drivers. The namespace structure shifted, and the specific class Doctrine\DBAL\Driver\PDOMySql\Driver was removed or renamed to align with the new abstraction layers. Consequently, if your composer.json currently specifies "doctrine/dbal": "~2.3" but Composer has resolved a dependency that pulls in a newer version of the package—potentially due to transitive dependencies from other installed packages—you will hit this error immediately upon attempting to execute migrations.

The solution involves ensuring your composer.json explicitly locks the correct version range that matches your Laravel installation. If you are running an older version of Laravel, you must strictly constrain the doctrine/dbal dependency to version 2.x. You can do this by editing the require section of your composer.json file:

"require": {
    "doctrine/dbal": "^2.13",
    // ... other dependencies
}

After updating the constraint, you must run composer update doctrine/dbal to resolve the dependency graph without replacing unrelated packages. This targeted approach ensures that you do not accidentally upgrade other critical components of your stack while fixing the driver compatibility issue.

It is important to note that simply adding the dependency to the file does not guarantee success if the version resolver picks up a newer peer dependency automatically. In scenarios where you cannot control all transitive dependencies, explicitly setting the version constraint in composer.json acts as a hard floor and ceiling for that specific library, preventing Composer from selecting an incompatible major version.

If you have recently migrated to a newer version of Laravel (8.0 or later), you likely need to upgrade your Doctrine DBAL to version 3. In that case, the error persists because Laravel's internal migration system may still be referencing the old class name before it has been updated to support the new driver architecture. However, since the source material indicates the user successfully created tables previously, this suggests the framework itself is functional and only the specific DBAL library state is corrupted or mismatched.

In such cases, running composer install or composer update after fixing the version constraint is sufficient. Avoid using composer require doctrine/dbal:^3.0 unless you have confirmed your Laravel version supports it, as this can break older applications that rely on the legacy driver interface. Always verify the installed versions by running composer show doctrine/dbal before and after making changes to confirm the resolution aligns with your framework's expectations.

Our network