簡體   English   中英

symfony2教程 - 生成包

[英]symfony2 tutorial - generate bundle

我是symfony2的新手,但不是symfony。 我目前正在做symblog教程 它到目前為止還不錯,但是我對生成包有點卡住了嗎?

該教程說要運行以下命令

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

完成之后,它應該將引用/生成代碼添加到包中

  • 應用程序/ 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]: 

您無需互動即可使用此功能。 然后它不會問你什么

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

來自generate:bundle --help

如果要禁用任何用戶交互,請使用--no-interaction但不要忘記傳遞所有需要的選項:

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。

如果我理解正確的是什么,你必須繼續這個過程。 這是您回答問題的一步一步。 繼續回答所有問題,然后控制台會告訴它何時創建了捆綁包。

注意:如果您在控制台詢問某事時只按Enter鍵,則[...]中的值為默認值。

舊命令:

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

在新的symfony版本3.1.4中, “app / console”不再有效。 而是在上面的命令中添加“bin / console”

所以新命令將是

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM