2013-01-23 36 views
3

我是symfony2的新手,但不是symfony。我目前在做the symblog tutorial。它到目前为止确定,但是我有一点卡在生成包?symfony2教程 - 生成包

的教程说运行下面的命令

php app/console generate:bundle --namespace=Blogger/BlogBundle --format=yml 

完成,它应该在

  • 应用添加参考/生成代码以束后/ AppKernel.php
  • 应用程序/ config/routing.yml

但是它没有添加任何东西?...我有点c onfused?控制台输出以下,但到包的代码引用没有在文件

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]: 
+1

要小心,这个教程是sf2.0.x.你正在使用哪个版本? – j0k

+0

2.1.7 - 也许即时调用错误的命令或使用它错误? –

+0

新版本的symfony的行为与本教程所期望的不同。 –

回答

9

您可以在没有交互的情况下使用它。那么它不会要求你什么

php app/console generate:bundle --namespace=Blogger/BlogBundle --format=yml --no-interaction 
+0

这是最好的答案。非常简洁。该教程应该有这个命令行。 –

1

已经产生。如果我的理解发生了什么正确的事情,你必须去的过程。它会一步步回答问题。继续回答所有问题,然后控制台会告诉它什么时候创建了捆绑包。

注意:如果您在控制台询问您时按下Enter键,则[...]中的值为默认值。

6

generate:bundle --help

如果要禁用任何用户交互,使用--no互动,但不要忘记通过所有需要的选项:

php app/console generate:bundle --namespace=Acme/BlogBundle --dir=src [--bundle-name=...] --no-interaction 

我的bash功能,这些长命令。

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

您可以像这样使用它:“genbundle Acme Blog”,它会在Acme应用程序中创建一个BlogBu​​ndle。

+0

+1命令 - 帮助。 –

0

旧命令:

php app/console generate:bundle --namespace=Blogger/BlogBundle --format=yml --no-interaction 

在新的symfony版本3.1.4,“应用程序/控制台”没有更多的工作。 而是添加“斌/控制台”在上面的命令

因此新命令将

php bin/console generate:bundle --namespace=Blogger/BlogBundle --format=yml --no-interaction