LaminasStorageCache issue after migration from Zend Framework 3 to Laminas

242 Views Asked by At

I migrated a project from Zend Framework 3 to Laminas.

Since I occur an error with Doctrine and DoctrineModule\Cache\LaminasStorageCache.

The message says: Service with name "DoctrineModule\Cache\LaminasStorageCache" could not be created. Reason: Could not resolve value for parameter "storage" of type Laminas\Cache\Storage\StorageInterface in class DoctrineModule\Cache\LaminasStorageCache (requested as DoctrineModule\Cache\LaminasStorageCache)

I haven't defined any "storage" parameter anywhere.

This error happend when I try to access to the database

$this->getServiceLocator()->get('Doctrine\ORM\EntityManager');

I can get the ServiceLocator, it returns an object, but can't reach the EntityManager. This EntityManager subcall the service locator several times to create a lot of instances of differents Laminas modules, and fails on the LaminasStorageCache as the error message said.

I have a simple MySQL in localhost and this simple configuration regarding Doctrine:

'doctrine' => array(
        'connection' => array(
            'orm_default' => array(
                'driverClass' => \Doctrine\DBAL\Driver\PDO\MySQL\Driver::class,
                'params' => array(
                    'host'     => 'localhost',
                    'port'     => '3306',
                    'user'     => 'root',
                    'password' => '',
                    'dbname'   => 'mybase',
                    'charset'  => 'utf8'
                )
            )
        ),

I don't understand this error and it's not linked to my application code, it comes from Laminas deep ^^ It should be a bad configuration but I can't figure out what :' I deep into the code and tried to configure the Doctrine cache, but without any difference.

If anyone can help me or explain me what I missed.

By the way, I would like to add that I have others projets, successfully migrated to Laminas, I don't see any difference in the configuration files and they works well.

EDIT : I deep down to Laminas\Di\Resolver\DependencyResolver and see

public function resolveParameters(string $requestedType, array $callTimeParameters = []): array
    {
        $definition = $this->getClassDefinition($requestedType);
        $params     = $definition->getParameters();
        $result     = [];
    [... and here $params is an array and contain storage...]
        foreach ($params as $paramInfo) {
    [...]
         // The parameter is required, but we can't find anything that is suitable
            if ($paramInfo->isRequired()) {
                $isAlias = $this->config->isAlias($requestedType);
                $class   = $isAlias ? $this->config->getClassForAlias($requestedType) : $requestedType;

                assert(is_string($class));

                throw new Exception\MissingPropertyException(sprintf(
                    'Could not resolve value for parameter "%s" of type %s in class %s (requested as %s)',
                    $name,
                    $type ?: 'any',
                    $class,
                    $requestedType
                ));
            }

            $result[$name] = new ValueInjection($paramInfo->getDefault());

That's the message displayed, and yes I misconfigured something but can't get what exactly. It looks for the 'storage' parameter, I didn't defined it. Help :)

1

There are 1 best solutions below

0
Bidoum On

Ok I found the issue by comparing my projects.

During the migration, laminas-di was automatically added as dependency. Doctrine plus laminas-di is a bit too much.

I removed laminas-di and this part works now !

Hope this can help someone else in the futur