メモ

【Symfony2】バンドルの登録とKernelへの登録

バンドルの登録とKernelへの登録のメモです。

自動更新OFF

バンドル作成時に、KernelとRoutingの自動更新をせずにgitへコミットしました。

Confirm automatic update of your Kernel [yes]? no
Enabling the bundle inside the Kernel: FAILED
Confirm automatic update of the Routing [yes]? no
Importing the bundle routing resource: FAILED

自動更新ON

バンドル作成時にKernelとRoutingの自動更新をした場合、以下の2つのファイルが更新されます。

更新内容は、自動更新をしない場合に表示されたメッセージどおりです。

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


- Edit C:\work\programming\php\Symfony2\app\AppKernel.php
  and add the following bundle in the AppKernel::registerBundles() method:

    new My\BlogBundle\MyBlogBundle(),

- Import the bundle's routing resource in the app main routing file:

    MyBlogBundle:
        resource: "@MyBlogBundle/Resources/config/routing.yml"
        prefix:   /

ルーティング

バンドルごとのルーティングだけでなく、プロジェクト全体のルーティングファイルも存在するようです。

ただし、パターンではなくバンドルのルーティングファイルを読み込んでいるようです。さらに、バンドルごとのルーティングが被らないように接頭辞をつけているようにです。あとで調べてみたいと思います。

AppKernel.php

そもそも、Kernelとは?

Symfony2のコアとなる部分です。フロントコントローラから生成されています。

<?php

require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/AppCache.php';

use Symfony\Component\HttpFoundation\Request;

$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
//$kernel = new AppCache($kernel);
$kernel->handle(Request::createFromGlobals())->send();

実際に使用するKernelは、Kernelを継承したAppKernelです。AppKernelには、Symfony2に必要なバンドルと今回追加したMyBlogBundleを登録しています。

また、Kernel生成時には環境とデバッグモードを指定します。その後、クラスを読み込み、これらのバンドルを使用して最終的にレスポンスを返すようです。

  1. 2012/01/29(日) 22:35:45|
  2. Symfony2
  3. | トラックバック:0
  4. | コメント:0
<<【php】クラス外でのconst | ホーム | 【Symfony2】バンドル作成と、その中身>>

コメント

コメントの投稿


管理者にだけ表示を許可する

トラックバック

トラックバック URL
http://ratememo.blog17.fc2.com/tb.php/820-76dcfe90
この記事にトラックバックする(FC2ブログユーザー)

プロフィール

Author:メモの人
自分の気づいたことなどを書くメモ帳(備忘録)です。メモした概要を自分の頭にindexとして残しておいて、参照するちょっと換わった使い方してます。

文章を書く力を身に付けるためのメモ帳でもあります。そのためにcssやhtmlを使用して意味のあるまとまりにできたらなと思います。

また、コメントや疑問がありましたら、気軽にお願いします。人見知りかつ一人が気楽でしたが、いろんな人と交流し楽しく成長できるようにがんばります。
github
Twitter
cloudControl

最近の記事

最近のコメント

最近のトラックバック

月別アーカイブ

カテゴリ

FC2カウンター

ブログ内検索

リンク

このブログをリンクに追加する