2013-01-23 34 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