在symfony2

时间:2015-05-21 12:53:29

标签: php symfony

有没有办法只显示一个命名空间的所有命令?例如,只有教义的所有命令?

因为我有很多命令和很多命令命名空间,所以非常好。

  

我知道| grep <namespace>但是如果它存在则寻找内置的symfony选项

     

鉴于我正在使用symfony2.0

1 个答案:

答案 0 :(得分:2)

仅输入命名空间的开头以列出可用命令:

$ php app/console doctrine

  [InvalidArgumentException]               
  Command "doctrine" is not defined.       
  Did you mean one of these?               
      doctrine:query:sql                   
      doctrine:query:dql                   
      doctrine:schema:drop                 
      doctrine:mapping:info                
      […]

但如果数字很低,它将不会显示所有命令:

$ php app/console doctrine:cache
  [InvalidArgumentException]                                                                                   
  Command "doctrine:cache" is ambiguous (doctrine:cache:clear-result, doctrine:cache:clear-query and 1 more).

也可以使用list命令,它将对命令进行排序并添加描述:

$ php app/console list doctrine
Symfony version 2.3.28 - app/dev/debug

Usage:
  command [options] [arguments]

Options:
  --help           -h Display this help message
  […]

Available commands for the "doctrine" namespace:
  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: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

$ php app/console list doctrine:cache
Symfony version 2.3.28 - app/dev/debug

[…]

Available commands for the "doctrine:cache" namespace:
  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