命令 "doctrine:generate:entities" 未定义
Command "doctrine:generate:entities" is not defined
我遇到 Symfony 和 Doctrine 实体生成器的问题。
当我调用 php app/console doctrine:generate:entities MyCompany
时,命令失败并抛出此异常:
[InvalidArgumentException]
Command "doctrine:generate:entities" is not defined.
Did you mean one of these?
doctrine:generate:entity
doctrine:generate:form
doctrine:generate:crud
我看到很多 post 人有类似的问题。但是他们的相关 doctrine:generate:entity
命令。他们忘记了 :
"sensio/generator-bundle": "2.3.*" // in composer.json
和
new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); // in AppKernel
在我的例子中,composer.json 和 AppKernel 一切正常。例如,这些命令有效:doctrine:generate:entity
、doctrine:generate:form
和 doctrine:generate:crud
但是 doctrine:generate:entities
没有 :/
这是我的 php app/console list
命令的摘录:
[...]
doctrine
doctrine:cache:clear-metadata Clears all metadata cache for an entity manager
doctrine:cache:clear-query Clears all query cache for an entity manager
doctrine:cache:clear-result Clears result cache for an entity manager
doctrine:database:create Creates the configured databases
doctrine:database:drop Drops the configured databases
doctrine:ensure-production-settings Verify that Doctrine is properly configured for a production environment.
doctrine:generate:crud Generates a CRUD based on a Doctrine entity
doctrine:generate:entity Generates a new Doctrine entity inside a bundle
doctrine:generate:form Generates a form type class based on a Doctrine entity
doctrine:mapping:convert Convert mapping information between supported formats.
doctrine:mapping:import Imports mapping information from an existing database
doctrine:mapping:info Shows basic information about all mapped entities
doctrine:query:dql Executes arbitrary DQL directly from the command line.
doctrine:query:sql Executes arbitrary SQL directly from the command line.
doctrine:schema:create Executes (or dumps) the SQL needed to generate the database schema
doctrine:schema:drop Executes (or dumps) the SQL needed to drop the current database schema
doctrine:schema:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata
doctrine:schema:validate Validates the doctrine mapping files
[...]
generate
generate:bundle Generates a bundle
generate:controller Generates a controller
generate:doctrine:crud Generates a CRUD based on a Doctrine entity
generate:doctrine:entity Generates a new Doctrine entity inside a bundle
generate:doctrine:form Generates a form type class based on a Doctrine entity
[...]
这里有一些关于我的项目供应商版本的信息
symfony/symfony v2.3.24 The Symfony PHP framework
sensio/framework-extra-bundle v2.3.4 This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle v2.3.5 This bundle generates code for you
doctrine/annotations v1.2.3 Docblock Annotations Parser
doctrine/cache v1.4.0 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.2 Collections Abstraction library
doctrine/common v2.4.2 Common Library for Doctrine projects
doctrine/dbal v2.4.4 Database Abstraction Layer
doctrine/doctrine-bundle v1.2.0 Symfony DoctrineBundle
doctrine/inflector v1.0.1 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm v2.4.7 Object-Relational-Mapper for PHP
感谢您的帮助! :)
好的,我找到了问题的解决方案,所以我 post 在这里回答,希望有一天它能对某人有所帮助 :)
命令 doctrine:generate:entities
由文件 DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php
(https://github.com/doctrine/DoctrineBundle/blob/v1.2.0/Command/GenerateEntitiesDoctrineCommand.php) 提供。而这个文件就莫名其妙的消失了!很奇怪...
为了解决这个问题,我删除了供应商的 doctrine/doctrine-bundle
文件夹和 运行 一个 composer update
瞧瞧:)
我遇到 Symfony 和 Doctrine 实体生成器的问题。
当我调用 php app/console doctrine:generate:entities MyCompany
时,命令失败并抛出此异常:
[InvalidArgumentException]
Command "doctrine:generate:entities" is not defined.
Did you mean one of these?
doctrine:generate:entity
doctrine:generate:form
doctrine:generate:crud
我看到很多 post 人有类似的问题。但是他们的相关 doctrine:generate:entity
命令。他们忘记了 :
"sensio/generator-bundle": "2.3.*" // in composer.json
和
new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); // in AppKernel
在我的例子中,composer.json 和 AppKernel 一切正常。例如,这些命令有效:doctrine:generate:entity
、doctrine:generate:form
和 doctrine:generate:crud
但是 doctrine:generate:entities
没有 :/
这是我的 php app/console list
命令的摘录:
[...]
doctrine
doctrine:cache:clear-metadata Clears all metadata cache for an entity manager
doctrine:cache:clear-query Clears all query cache for an entity manager
doctrine:cache:clear-result Clears result cache for an entity manager
doctrine:database:create Creates the configured databases
doctrine:database:drop Drops the configured databases
doctrine:ensure-production-settings Verify that Doctrine is properly configured for a production environment.
doctrine:generate:crud Generates a CRUD based on a Doctrine entity
doctrine:generate:entity Generates a new Doctrine entity inside a bundle
doctrine:generate:form Generates a form type class based on a Doctrine entity
doctrine:mapping:convert Convert mapping information between supported formats.
doctrine:mapping:import Imports mapping information from an existing database
doctrine:mapping:info Shows basic information about all mapped entities
doctrine:query:dql Executes arbitrary DQL directly from the command line.
doctrine:query:sql Executes arbitrary SQL directly from the command line.
doctrine:schema:create Executes (or dumps) the SQL needed to generate the database schema
doctrine:schema:drop Executes (or dumps) the SQL needed to drop the current database schema
doctrine:schema:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata
doctrine:schema:validate Validates the doctrine mapping files
[...]
generate
generate:bundle Generates a bundle
generate:controller Generates a controller
generate:doctrine:crud Generates a CRUD based on a Doctrine entity
generate:doctrine:entity Generates a new Doctrine entity inside a bundle
generate:doctrine:form Generates a form type class based on a Doctrine entity
[...]
这里有一些关于我的项目供应商版本的信息
symfony/symfony v2.3.24 The Symfony PHP framework
sensio/framework-extra-bundle v2.3.4 This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle v2.3.5 This bundle generates code for you
doctrine/annotations v1.2.3 Docblock Annotations Parser
doctrine/cache v1.4.0 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.2 Collections Abstraction library
doctrine/common v2.4.2 Common Library for Doctrine projects
doctrine/dbal v2.4.4 Database Abstraction Layer
doctrine/doctrine-bundle v1.2.0 Symfony DoctrineBundle
doctrine/inflector v1.0.1 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm v2.4.7 Object-Relational-Mapper for PHP
感谢您的帮助! :)
好的,我找到了问题的解决方案,所以我 post 在这里回答,希望有一天它能对某人有所帮助 :)
命令 doctrine:generate:entities
由文件 DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php
(https://github.com/doctrine/DoctrineBundle/blob/v1.2.0/Command/GenerateEntitiesDoctrineCommand.php) 提供。而这个文件就莫名其妙的消失了!很奇怪...
为了解决这个问题,我删除了供应商的 doctrine/doctrine-bundle
文件夹和 运行 一个 composer update
瞧瞧:)