このチュートリアルを読み、Zend2 プロジェクト内で Doctrine2 をセットアップしようとしました。
- Doctrine2 を依存関係として登録し、正常にインストールしました
チュートリアルに従って、エンティティを持ちたい2つのモジュールの構成にドクトリンエンティティパスを登録しました。
namespace MyNamespace; return array( 'doctrine' => array( 'driver' => array( __NAMESPACE__ . '_driver' => array( 'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', 'cache' => 'array', 'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Doctrine/Entity') ), 'orm_default' => array( 'drivers' => array( __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver' ) ) ) ), 'view_manager' => array( 'template_path_stack' => array( 'PBT' => __DIR__ . '/../view' ), ), );
私は非常に単純なエンティティを宣言しました:
namespace MyNamespace\Doctrine\Entity; use Doctrine\ORM\Mapping as ORM; class User { /** * @ORM\Id * @ORM\Column(type="integer", name="id"); * @ORM\GeneratedValue(strategy="AUTO") */ protected $_id; /** * @ORM\Column(type="string", name="email") */ protected $_email; /** * @ORM\Column(type="string", name="passwordHash") */ protected $_passwordHash; }
データベースにテーブルを作成することを期待して、doctrine コマンドを実行しました。
./vendor/bin/doctrine-module migrations:generate
ここで発生したエラー:
PHP Fatal error: Uncaught exception 'Zend\Mvc\Router\Exception\RuntimeException' with message 'Given route does not implement Console route interface' in PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Router/Console/SimpleRouteStack.php:81
Stack trace:
#0 PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Router/Console/SimpleRouteStack.php(51): Zend\Mvc\Router\Console\SimpleRouteStack->routeFromArray(Array)
#1 PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Router/SimpleRouteStack.php(140): Zend\Mvc\Router\Console\SimpleRouteStack->addRoute('home', Array)
#2 PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Router/SimpleRouteStack.php(84): Zend\Mvc\Router\SimpleRouteStack->addRoutes(Array)
#3 [internal function]: Zend\Mvc\Router\SimpleRouteStack::factory(Array)
#4 truncated mention to 'PROJECT_DIR' in PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 860
Fatal error: Uncaught exception 'Zend\Mvc\Router\Exception\RuntimeException' with message 'Given route does not implement Console route interface' in PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 860
Zend\Mvc\Router\Exception\RuntimeException: Given route does not implement Console route interface in PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Router/Console/SimpleRouteStack.php on line 81
Call Stack:
0.0001 633648 1. {main}() PROJECT_DIR/vendor/doctrine/doctrine-module/bin/doctrine-module:0
0.0458 650288 2. include('PROJECT_DIR/vendor/doctrine/doctrine-module/bin/doctrine-module.php') PROJECT_DIR/vendor/doctrine/doctrine-module/bin/doctrine-module:4
0.1666 878808 3. Zend\Mvc\Application::init() PROJECT_DIR/vendor/doctrine/doctrine-module/bin/doctrine-module.php:46
1.6689 5914064 4. Zend\Mvc\Application->bootstrap() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:254
1.6999 6515856 5. Zend\ServiceManager\ServiceManager->get() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:153
1.6999 6516648 6. Zend\ServiceManager\ServiceManager->create() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:481
1.6999 6516648 7. Zend\ServiceManager\ServiceManager->doCreate() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:557
1.6999 6516728 8. Zend\ServiceManager\ServiceManager->createFromFactory() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:598
1.7011 6537712 9. Zend\ServiceManager\ServiceManager->createServiceViaCallback() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:983
1.7011 6538200 10. call_user_func() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:853
1.7011 6538272 11. Zend\Mvc\Service\RouterFactory->createService() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:853
1.7013 6540728 12. call_user_func() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Service/RouterFactory.php:65
1.7058 6689416 13. Zend\Mvc\Router\SimpleRouteStack::factory() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Service/RouterFactory.php:65
1.7071 6742992 14. Zend\Mvc\Router\SimpleRouteStack->addRoutes() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Router/SimpleRouteStack.php:84
1.7071 6743848 15. Zend\Mvc\Router\Console\SimpleRouteStack->addRoute() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Router/SimpleRouteStack.php:140
1.7071 6743928 16. Zend\Mvc\Router\Console\SimpleRouteStack->routeFromArray() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Router/Console/SimpleRouteStack.php:51
Zend\ServiceManager\Exception\ServiceNotCreatedException: An exception was raised while creating "Router"; no instance returned in PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 860
Call Stack:
0.0001 633648 1. {main}() PROJECT_DIR/vendor/doctrine/doctrine-module/bin/doctrine-module:0
0.0458 650288 2. include('PROJECT_DIR/vendor/doctrine/doctrine-module/bin/doctrine-module.php') PROJECT_DIR/vendor/doctrine/doctrine-module/bin/doctrine-module:4
0.1666 878808 3. Zend\Mvc\Application::init() PROJECT_DIR/vendor/doctrine/doctrine-module/bin/doctrine-module.php:46
1.6689 5914064 4. Zend\Mvc\Application->bootstrap() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:254
1.6999 6515856 5. Zend\ServiceManager\ServiceManager->get() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php:153
1.6999 6516648 6. Zend\ServiceManager\ServiceManager->create() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:481
1.6999 6516648 7. Zend\ServiceManager\ServiceManager->doCreate() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:557
1.6999 6516728 8. Zend\ServiceManager\ServiceManager->createFromFactory() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:598
1.7011 6537712 9. Zend\ServiceManager\ServiceManager->createServiceViaCallback() PROJECT_DIR/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:983
すべての素晴らしいアイデアまたはそうでないアイデアを歓迎します...私の質問でコード表示を修正する方法を見つけたら、どうぞ...お気軽に!
編集: 完全なエラー ダンプを追加しました。コマンド ラインだけがクラッシュしているだけで、Web を経由するものはすべて機能していることに注意してください。