2

私はたまたま創造のすべてのsymfonyの問題を抱えています...

新しいプロジェクトを作りたいです。

' symfony2 'フォルダーをコピーし、名前を変更します。

 php app/console generate:bundle

それは言う:

  Generating the bundle code: OK
  Checking that the bundle is autoloaded: FAILED
  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.                      

  - Edit the composer.json file and register the bundle
  namespace in the "autoload" section:

  Bundle MddevPsavBundle is already imported.

どうしてこれなの?前回同じコマンドを実行したときにその問題が発生しなかったのはいつですか?

どうすればこれを正確に解決できますか?そして、私はそのファイルに正確に何を追加しcomposer.jsonますか?

私は何かを試しましたが、次のようになります。

  Fatal error: Class 'Mddev\PsavBundle\MddevPsavBundle' not found in
  /var/www/projetQ/app/AppKernel.php on line 22
4

7 に答える 7

10

問題が発生している場合:

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

次に、次のように指示します。

- Edit the composer.json file and register the bundle
namespace in the "autoload" section:

バンドルの命名規則に正しく従っていると仮定すると、次のことを行う必要があります。


新しいバンドルを composer.json ファイルに追加します

"autoload": {
    "psr-0": {
        "currentbundle\\": "src/",
        "YOURNEWBUNDLE\\": "src/",            
    }
}

その後、再度 composer で install を実行する必要があります

composer -n install --dev

次に、両方のバンドルを自動ロードする必要があります

于 2013-08-13T09:50:07.077 に答える
2

バンドルの名前空間が規則に従っていないようです: http://symfony.com/doc/current/cookbook/bundles/best_practices.html#bundle-name

Mddev\Bundle\MddevPsavBundleorMddev\MddevPsavBundleをバンドル名前空間として使用する必要があります。

于 2012-11-04T21:46:33.737 に答える
2

私はちょうどこの正確な問題を抱えていました。app/console generate:bundle が自動ロード チェックに失敗し、src ディレクトリが作成されませんでした。私はデフォルトの回答に慣れすぎていたので、src ディレクトリがキャッシュ ディレクトリを指していることに気づきませんでした。

適切なパスを入力したところ、すべて問題ありませんでした。

親しみやすさは本当に軽蔑を生むと思います。

于 2014-05-25T21:35:04.217 に答える
0

generate:bundle を実行する前に composer をインストールしていなかったため、エラーが発生しました。

composerをインストールしたら、コマンドを再試行しました(バンドルが作成したファイルとapp/AppKernal.phpからのコードを削除した後)、すぐに機能しました

于 2014-04-05T12:40:17.430 に答える
0

コマンド ラインからバンドルを生成する場合、ジェネレーターはバンドルが存在するディレクトリを考慮しません。これにより、ベンダー プレフィックスをバンドルに追加する際に問題が発生する可能性があります。これを機能させるには、2 つのことを確認する必要があります。

  1. 名前空間をチェックAppKernel.php>registerBundles()
  2. バンドルのクラスの名前空間を確認してください
  3. composer updateオートローダーが正しく作成されていることを確認するためだけに実行します

例:- namespace Acme\UserBundle;UserBundle.php 内

|-----|
|    src
|       |
|      Acme
|          |
|        UserBundle
|               .
|               .
|           UserBundle.php

そして中AppKernel.phpにはnew Acme\UserBundle\UserBundle(),

于 2016-05-28T12:21:23.083 に答える