Migrating Laminas MVC to php8.2 and doctrine error

Hello I am struggling to solve this error for hours now, I have working website originally build with Zend version2, and migrated to Laminas MVC on PHP7.2. Everything was fine with Doctrine module and etc. Now we are upgrading to PHP8.2.

This line in controller factory started throwing error, and says “DoctrineModule\Cache\LaminasStorageCache::__construct(): Argument #1 ($storage) must be of type Laminas\Cache\Storage\StorageInterface, string given, called in /pojectpath/vendor/doctrine/doctrine-module/src/Service/CacheFactory.php on line 63”

$entityManager = $container->get('doctrine.entitymanager.orm_default');

in composer.json, I have these installed.

        "laminas/laminas-component-installer": "^3.2",
        "laminas/laminas-development-mode": "^3.10",
        "laminas/laminas-skeleton-installer": "^1.2",
        "laminas/laminas-mvc": "^3.6.0",
        "laminas/laminas-mail": "^2.23",
        "laminas/laminas-db": "^2.18",
        "laminas/laminas-mvc-i18n": "^1.7",
        "laminas/laminas-serializer": "^2.16",
        "laminas/laminas-paginator": "^2.17",
        "laminas/laminas-inputfilter": "^2.27",
        "laminas/laminas-hydrator": "^4.14",
        "laminas/laminas-session": "^2.16",
        "laminas/laminas-form": "^3.13",
        "laminas/laminas-authentication": "^2.15",
        "doctrine/doctrine-orm-module": "^6.0",
        "doctrine/migrations": "^3.6",
        "laminas/laminas-cache-storage-adapter-blackhole": "^2.3"

Please let me know how to solve this issue. Many thanks.

somehow I could solve it so let me share my issues.

I have several issues layered underneath,
1 : I had to change config/local or global.php, udpate strucrure of cache and FilesystemCache.
2 : added more dependencies. here is my latest composer.json

        "laminas/laminas-component-installer": "^3.2",
        "laminas/laminas-development-mode": "^3.10",
        "laminas/laminas-skeleton-installer": "^1.2",
        "laminas/laminas-mvc": "^3.6.0",
        "laminas/laminas-mail": "^2.23",
        "laminas/laminas-db": "^2.18",
        "laminas/laminas-mvc-i18n": "^1.7",
        "laminas/laminas-serializer": "^2.16",
        "laminas/laminas-paginator": "^2.17",
        "laminas/laminas-inputfilter": "^2.27",
        "laminas/laminas-hydrator": "^4.14",
        "laminas/laminas-session": "^2.16",
        "laminas/laminas-form": "^3.13",
        "laminas/laminas-authentication": "^2.15",
        "doctrine/doctrine-orm-module": "^6.0",
        "doctrine/migrations": "^3.6",
        "laminas/laminas-cache-storage-adapter-blackhole": "^2.3",
        "laminas/laminas-cache": "^3.11",
        "doctrine/dbal": "^3.6"

3 : Then I got new error says “The given ‘driverClass’ Doctrine\DBAL\Driver\PDOMySql\Driver has to implement the Doctrine\DBAL\Driver interface”. Then I realize, DBAL path is changed. I had it

use Doctrine\DBAL\Driver\PDOMySql\Driver

but it has to be

use Doctrine\DBAL\Driver\PDO\MySql\Driver

Then all works on php8.2.

Sorry for making mess. I thought I had solve issues but I guess I didn’t. Not sure how and why but it works fine on locally, but on server, I get error says

“vendor/laminas/laminas-servicemanager/src/ServiceManager.php:649”
“Service with name “doctrine.connection.orm_default” could not be created. Reason: The given ‘driverClass’ Doctrine\DBAL\Driver\PDOMySql\Driver has to implement the Doctrine\DBAL\Driver interface”
and this is the driver in config/local.php

orm_default’ => [
‘driverClass’ => ‘Doctrine\DBAL\Driver\PDO\MySql\Driver’,
]

I am using Plesk and PHP8.2. If anyone knows how to solve this issue, please let me know. Many thanks!!

It was my typo. On local mac isn’t case sensitive. That’s why uploaded to Linux server, and stopped working.

this isn’t working

use Doctrine\DBAL\Driver\PDO\MySql\Driver;

this is working.

use Doctrine\DBAL\Driver\PDO\MySQL\Driver;

just so share, found document about dbal path change on v3.6

  • PDOMySql\DriverPDO\MySQL\Driver
  • PDOOracle\DriverPDO\OCI\Driver
  • PDOPgSql\DriverPDO\PgSQL\Driver
  • PDOSqlite\DriverPDO\SQLite\Driver
  • PDOSqlsrv\DriverPDO\SQLSrv\Driver
  • PDOSqlsrv\ConnectionPDO\SQLSrv\Connection
  • PDOSqlsrv\StatementPDO\SQLSrv\Statement