symfony2教程 - 生成包

Rob*_*_UK 3 php bundle symfony symfony-2.1

我是symfony2的新手,但不是symfony.我目前正在做symblog教程.它到目前为止还不错,但是我对生成包有点卡住了吗?

该教程说要运行以下命令

php app/console generate:bundle --namespace=Blogger/BlogBundle --format=yml
Run Code Online (Sandbox Code Playgroud)

完成之后,它应该将引用/生成代码添加到包中

  • 应用程序/ AppKernel.php
  • 应用程序/配置/ routing.yml中

但它没有添加任何东西?...我有点困惑?控制台输出以下内容,但尚未在文件中生成对包的代码引用

Welcome to the Symfony2 bundle generator  



Your application code must be written in bundles. This command helps
you generate them easily.

Each bundle is hosted under a namespace (like Acme/Bundle/BlogBundle).
The namespace should begin with a "vendor" name like your company name, your
project name, or your client name, followed by one or more optional category
sub-namespaces, and it should end with the bundle name itself
(which must have Bundle as a suffix).

See http://symfony.com/doc/current/cookbook/bundles/best_practices.html#index-1 for more
details on bundle naming conventions.

Use / instead of \  for the namespace delimiter to avoid any problem.

Bundle namespace [Blogger/BlogBundle]: 
Run Code Online (Sandbox Code Playgroud)

Ran*_*ngh 11

您无需互动即可使用此功能.然后它不会问你什么

php app/console generate:bundle --namespace=Blogger/BlogBundle --format=yml --no-interaction
Run Code Online (Sandbox Code Playgroud)


MGP*_*MGP 6

generate:bundle --help

如果要禁用任何用户交互,请使用--no-interaction但不要忘记传递所有需要的选项:

php app/console generate:bundle --namespace=Acme/BlogBundle --dir=src [--bundle-name=...] --no-interaction
Run Code Online (Sandbox Code Playgroud)

我有这些长命令的bash函数.

genbundle () {
    php app/console generate:bundle --namespace=$1/$2Bundle --bundle-name=$2Bundle --dir=src/ --format=yml
}
Run Code Online (Sandbox Code Playgroud)

您可以像这样使用它:"genbundle Acme Blog",它将在Acme应用程序中创建一个BlogBu​​ndle.