DASPRiD / container-interop-doctrine

Doctrine factories for container-interop
107 stars 25 forks source link

[CLI] Unable to resolve service "Config" to a factory; #32

Closed guillaumemaka closed 4 years ago

guillaumemaka commented 6 years ago

ZE 3 Dependencies

"php": "^7.1"
"dasprid/container-interop-doctrine": "^1.1",
"doctrine/doctrine-module": "^2.1"
"zendframework/zend-expressive": "^3.0.1"

I followed the CLI integration in the README but I got this exception when I run php vendor/bin/doctrine

PHP Fatal error:  Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: Unable to resolve service "Config" to a factory; are you certain you provided it during configuration? in /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/zendframework/zend-servicemanager/src/ServiceManager.php:687
Stack trace:
#0 /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(763): Zend\ServiceManager\ServiceManager->getFactory('Config')
#1 /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(200): Zend\ServiceManager\ServiceManager->doCreate('Config')
#2 /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/doctrine/doctrine-module/src/DoctrineModule/ServiceFactory/AbstractDoctrineServiceFactory.php(82): Zend\ServiceManager\ServiceManager->get('Config')
#3 /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/doctrine/doctrine-module/src/DoctrineModule/ServiceFactory/AbstractDoctrineServiceFactory. in /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 687

Fatal error: Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: Unable to resolve service "Config" to a factory; are you certain you provided it during configuration? in /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/zendframework/zend-servicemanager/src/ServiceManager.php:687
Stack trace:
#0 /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(763): Zend\ServiceManager\ServiceManager->getFactory('Config')
#1 /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(200): Zend\ServiceManager\ServiceManager->doCreate('Config')
#2 /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/doctrine/doctrine-module/src/DoctrineModule/ServiceFactory/AbstractDoctrineServiceFactory.php(82): Zend\ServiceManager\ServiceManager->get('Config')
#3 /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/doctrine/doctrine-module/src/DoctrineModule/ServiceFactory/AbstractDoctrineServiceFactory. in /Users/guillaume/Google Drive/UQTR/Stage/code/ebos/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 687

And I need to add this line in cli-config.php

$container->setAlias('Config', 'config');

Maybe add it to the README or if you have a workaround I would like to know it.

Thanks for awesome work.

asgrim commented 6 years ago

Could go a couple of ways here; this used to not matter way back before ServiceManager normalised the names. Could either document it or explicitly support both (look for Config then fall back to config perhaps) to silently support everything. Thoughts @DASPRiD ?

DASPRiD commented 6 years ago

I'd say that we should just document that we expect a configuration registered under the "config" key.

asgrim commented 6 years ago

I believe the convention set in Expressive 3+ is config so I'd prefer to go with that. However, this would be a BC break though as those who currently rely on Config would be broken...

DASPRiD commented 6 years ago

Not really – When I wrote this library, ServiceManager 3 was already out, so that was what I was already basing it on. It was never intended to account for people relying on normalization by their container.

asgrim commented 6 years ago

That's my point; the convention is config not Config. IMO its going to be better to just support both. I realise without thinking I've always just aliased config and Config because there's been a mismatch. If I find some time I'll get a patch together.

asgrim commented 6 years ago

Oh, meant to reference: https://github.com/zendframework/zend-expressive-skeleton/blob/master/src/ExpressiveInstaller/Resources/config/container-zend-servicemanager.php

DASPRiD commented 6 years ago

Don't forget to also support all other variations then, plus "Configuration", "configuration" and so on :P… uhm no, People can just use aliases on their container end.

asgrim commented 6 years ago

There's a line.. config/Config confusion was caused upstream in ZF/Expressive, so I don't think it's a big ask to support both. Similarly I don't think there's any need to go overboard and support every possible permutation. I'm just suggesting we go with the typical conventions of the ecosystem...

DASPRiD commented 6 years ago

I don't think we should support/enhance that confusion even further. Also, this is a report by a single user. It would be a different case if a larger percentage of the userbase would report this as an issue.

asgrim commented 6 years ago

As I already said, I've had this issue the whole time, I just didn't really think about it ;)

asgrim commented 4 years ago

This repository is now deprecated. If you are still experiencing this issue, please feel free to open a new issue at https://github.com/Roave/psr-container-doctrine/issues - thanks!