Unable to resolve service error

Just as a follow up.

@froschdesign @ezkimo

The composer tips you gave me… I was unaware, of the unused package, and had seen reference to why but had never used it so did not even think to use it in my situation. Tremendously insightful. In the end, I removed Di completely. Doing so helped clean up my code some because after that error was resolved I ended up facing two more that was easier to fix. I had mistakenly requested an instance of the EventManager from the container using its FQCN instead of the string, which did not work. Was receiving the same Unable to resolve service to factory error for the EventManager. After that was resolved I faced an error because I had done the same for the JsonStrategy. Again, using its FQCN instead of the string ‘ViewJsonStrategy’ caused my issue. I think the documentation should be more explicit about which services should be called by their string identifiers and which should not be. Maybe its explained somewhere and I either overlooked it, which in entirely possible, or just have not read that section of the documentation yet.
Once the Di was removed and the AuthenticationServiceFactory, very similar to froschdesign’s posted solution, was in place I attached the Authentication Validator to my login fieldset which simplified the code tremendously. I also changed the factory to pass a custom container name for the AuthenticationService Storage.

Thank you both for the help. Its greatly appreciated.

Edit to add an inquiry. Would those string identifiers be considered their aliases or the actual service names in these cases? I would think that if they were aliases then calling the FQCN would have returned the same instance, but it appears that it does not. Any clarification would be helpful.

The documentation of laminas-mvc lists the default services with their names:

For historical reasons, almost only names that are independent of the class names are actually used.

See also in source code:

1 Like

@froschdesign exactly what I needed!!!