Migration from Zf2

How to map factories written in the group of service manager in zf2 to laminas. Controller factories are working good

Not working showing path error - "Unable to resolve service “Application\Service\UserServiceInterface” to a factory; are you certain you provided it during configuration?

    'service_manager' => [
        'abstract_factories' => [
            'Laminas\Cache\Service\StorageCacheAbstractServiceFactory',
            'Laminas\Log\LoggerAbstractServiceFactory',
        ],
        'invokables' => [
        ],
        'aliases' => [
            'translator' => 'MvcTranslator',
        ],
        'factories' => [
            'Application\Service\UserServiceInterface' => 'Application\Factory\UserServiceFactory',
        ],
]

Thanks

Are you sure the given factory exists under the given full qualified class name? I suggest using the ::class keyword instead of strings. Strings tend to be errornous. Current IDEs like PHPStorm or VSCode support code completion when using the ::class keyword.

<?php
declare(strict_types=1);
namespace Application;

return [
    'service_manager' => [
        'factories' => [
            // will resolve into fully qualified class names
            // Application\Service\UserServiceInterface and
            // Application\Service\Factory\UserServiceFactory
            Service\UserServiceInterface::class => Service\Factory\UserServiceFactory::class,
        ],
    ],
];

Since you 've noted a namespace at the beginning, everything will extend the namespace when not using a backslash at the first position. You can use the ::class keyword even on classes, that actually don 't exist.

Please check, if the php file is available at /modules/Application/src/Factory/UserServiceFactory.php. If the file is available, you can check the class name. Is the class name really UserServiceFactory?

Did you check for PSR Service Container? Laminas has changed its behaviour regarding factories. To get lost of the dependency to the old Zend Framework 2 service container, just use the psr service container instead. The psr container should always be your first choice. Please avoid using old service container implementations.

<?php
declare(strict_types=1);
namespace Application\Factory;

use Application\Foo\SomethingFromTheServiceManager;
use Psr\Container\ContainerInterface;

class UserServiceFactory
{
    public function __invoke(ContainerInterface $container): UserServiceInterface
    {
        $somethingFromTheServiceManager = $container->get(SomethingFromTheServiceManager::class);
        return new UserService($somethingFromTheServiceManager);
    }
}

Optionally the __invoke method can have the good old $requestedName and $options parameters. I have simply omitted it for the sake of simplicity.

Thanks @ezkimo for the detailed explanations.

When i updated the paths as you suggested it started connecting to the Service and Factory. In Index factory i had made modification with __invoke.