Php 如何使用命令行工具为ZF2和条令生成“getter/setter”?

Php 如何使用命令行工具为ZF2和条令生成“getter/setter”?,php,doctrine-orm,zend-framework2,doctrine,Php,Doctrine Orm,Zend Framework2,Doctrine,如何使用命令行工具为ZF2和条令生成getter/setter?比如$myEntity->getUsername()和$myEntity->setUsername('foo'); 我用它来生成实体: ./vendor/bin/doctrine-module orm:convert-mapping --force --from-database annotation ./Entity/ 我使用这个脚本 这对我真的很有帮助。像这样使用它: php generateGettersAndSetters

如何使用命令行工具为ZF2和条令生成getter/setter?比如$myEntity->getUsername()和$myEntity->setUsername('foo'); 我用它来生成实体:

./vendor/bin/doctrine-module orm:convert-mapping --force --from-database annotation ./Entity/
我使用这个脚本 这对我真的很有帮助。像这样使用它:

php generateGettersAndSetters.php file.php > generatedFile.php

您不需要使用第三方脚本,因为您使用的是
DoctrineORMModule
。条令的原生
ConvertMapping
命令已经为我们提供了所需的选项

您只需将
true
作为
generate methods
参数值传递给CLI,如下所示:

$ cd /path/to/your/project
$ php public/index.php orm:convert-mapping --from-database annotation ./Entity/ --update-entities="true" --generate-methods="true"

谢谢Mostafa!它工作得完美无缺。(myfelf注意:总有一天我会后悔执行我在stackoverflow上看到的命令行指令)。