2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Symfony3.4でのBundle追加手順

Posted at

環境

  • LinuxまたはMacOS
  • PHP 5.6以上
  • Composer
  • Symfony 3.4

Bundleの追加

AdminBundleという管理画面用のBundleを追加する例で記載します。
手順は公式サイトの通りですが、オプションを指定すると次のように1行で生成できます。

# コンソールで実行
php bin/console generate:bundle --namespace=AdminBundle --format=annotation --no-interaction

composer.jsonへの追加

次のような文章が表示された場合、composer.jsonを修正する必要があります。

The command was not able to configure everything automatically.
You'll need to make the following changes manually.

composer.jsonファイルはSymfonyプロジェクトの一番上の階層にあります。
編集内容は次のサンプルの3行目のように、
"AdminBundle\\": "src/AdminBundle",
を追加します。

composer.json
"autoload": {
    "psr-4": {
        "AdminBundle\\": "src/AdminBundle",
        "AppBundle\\": "src/AppBundle"
    },

その後、次のコマンドを実行します。

# コンソールで実行
composer dump-autoload
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?