Apigility - How to use Doctrine ORM Module from ZF

2019-07-15 09:55发布

问题:

Hi i'm new with Apigility. Im trying to configure doctrine-orm-module. When i tried to run the command below and getting this error

$ cd /var/www/apigility/zf-apigility-skeleton/vendor/doctrine/doctrine-module/bin
$ php doctrine-module.php

Error is:

PHP Fatal error:  Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.cli' in /var/www/apigility/zf-apigility-skeleton/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:529
Stack trace:
#0 /var/www/apigility/zf-apigility-skeleton/vendor/doctrine/doctrine-module/bin/doctrine-module.php(51): Zend\ServiceManager\ServiceManager->get('doctrine.cli')
#1 {main} thrown in /var/www/apigility/zf-apigility-skeleton/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 529

Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException' with message 'Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for doctrine.cli' in /var/www/apigility/zf-apigility-skeleton/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:529
Stack trace:
#0 /var/www/apigility/zf-apigility-skeleton/vendor/doctrine/doctrine-module/bin/doctrine-module.php(51): Zend\ServiceManager\ServiceManager->get('doctrine.cli')
#1 {main} thrown in /var/www/apigility/zf-apigility-skeleton/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 529

I followed the installation guide on DoctrineORMModule's readme.md

回答1:

You don't need to run doctrine-module cli directly inside the bin folder. DoctrineModule already binds related console routes to the application if it's configured correctly.

Try this:

$ cd /var/www/apigility/zf-apigility-skeleton
$ php public/index.php orm:info

Hope it helps.