0

Symfony: バンドル ルーティング リソースのインポートに関する問題

Symfony アプリ コンソールを使用してバンドルを生成しようとしていますが、

$ php app/console generate:bundle

しかし、私はエラーが発生し続けます

    Confirm automatic update of the Routing [yes]? 

バンドル ルーティング リソースのインポート: FAILED

このコマンドは、すべてを自動的に構成できませんでした。
次の変更は手動で行う必要があります。

バンドル PulsestormHelloworldBundle は既にインポートされています。

これを解決する方法を知っている人はいますか?言い換えれば、このエラーの一般的な原因は何か、具体的にはアプリ コンソールが Routing の自動更新を実行するときに何をしているのかということです。それがなければ、ソース コードに飛び込んで、これが失敗する理由についてデバッグ ハッキングを開始するのに理想的な場所はありますか?

コンテキスト: 私は経験豊富なプログラマーですが、Symfony の開発に関しては初心者です。チュートリアルに沿って従う新しいバンドルを生成しました。しかし、yaml/yml 形式ではなくアノテーション形式を使用して誤ってバンドルを作成してしまったことに気付きました。違いがわからないので、バンドルを再生成したかったのです。これをする

  1. からバンドル宣言を削除しましたAppKernel

  2. スクリプトapp/bootstrap.php.cacheを使用してファイルを再生成しましたbuild_bootstrap.php

  3. バンドルが生成されたフォルダーから、バンドルのソース コードを削除しましたsrc(それ以外の場合、このフォルダーは空です)。

ただし、generate:bundleコマンドステップを実行するたびに、常に終了します

Confirm automatic update of the Routing [yes]? 

バンドル ルーティング リソースのインポート: FAILED

このコマンドは、すべてを自動的に構成できませんでした。
次の変更は手動で行う必要があります。

バンドル PulsestormHelloworldBundle は既にインポートされています。

したがって、私のコードベースには、このエラーの原因となっている前世代の試行からの人工物があると思いますが、これを追跡するのに十分な Symfonyt の経験がありません。

トラブルシューティングに役立つ場合に備えて、CLI のやり取り全体を以下に含めました。

$ php app/console generate:bundle


  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: Pulsestorm/Bundle/HelloworldBundle

In your code, a bundle is often referenced by its name. It can be the
concatenation of all namespace parts but it's really up to you to come
up with a unique name (a good practice is to start with the vendor name).
Based on the namespace, we suggest PulsestormHelloworldBundle.

Bundle name [PulsestormHelloworldBundle]: 

The bundle can be generated anywhere. The suggested default directory uses
the standard conventions.

Target directory [/Users/alanstorm/Documents/github_oro/crm-application/src]: 

Determine the format to use for the generated configuration.

Configuration format (yml, xml, php, or annotation) [annotation]: yml

To help you get started faster, the command can generate some
code snippets for you.

Do you want to generate the whole directory structure [no]? yes


  Summary before generation  


You are going to generate a "Pulsestorm\Bundle\HelloworldBundle\PulsestormHelloworldBundle" bundle
in "/Users/alanstorm/Documents/github_oro/crm-application/src/" using the "yml" format.

Do you confirm generation [yes]? 


  Bundle generation  


Generating the bundle code: OK
Checking that the bundle is autoloaded: OK
Confirm automatic update of your Kernel [yes]? 
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]? 
Importing the bundle routing resource: FAILED


  The command was not able to configure everything automatically.  
  You must do the following changes manually.                      


Bundle PulsestormHelloworldBundle is already imported.
4

1 に答える 1

3

私が疑ったように、問題は画面とキーボードの間にありました。Symfony の各バンドルには独自のrouting.ymlファイルがある場合がありますが、次の場所にマスター ファイルがあります。

app/config/routing.yml

このファイルは、個々のバンドルのルーティング ファイルを指します。「バンドル ルーティング リソースをインポートする」とは、このファイルに構成エントリを追加することです。

#app/config/routing.yml
pulsestorm_helloworld:
    resource: "@PulsestormHelloworldBundle/Resources/config/routing.yml"
    prefix:   /

このファイルのことを知らなかったのでapp/config/routing.yml、以前に追加した構成を削除できませんでした。これは、コンソール アプリケーションが不満を持っていたものです。マスターの routing.yml ファイルから上記を削除すると、バンドル生成のクリーンな実行を取得できました。

于 2013-06-22T18:55:54.973 に答える