バンドルの登録とKernelへの登録のメモです。
バンドル作成時に、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
バンドル作成時に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: /
バンドルごとのルーティングだけでなく、プロジェクト全体のルーティングファイルも存在するようです。
ただし、パターンではなくバンドルのルーティングファイルを読み込んでいるようです。さらに、バンドルごとのルーティングが被らないように接頭辞をつけているようにです。あとで調べてみたいと思います。
そもそも、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生成時には環境とデバッグモードを指定します。その後、クラスを読み込み、これらのバンドルを使用して最終的にレスポンスを返すようです。
Author:メモの人
自分の気づいたことなどを書くメモ帳(備忘録)です。メモした概要を自分の頭にindexとして残しておいて、参照するちょっと換わった使い方してます。
文章を書く力を身に付けるためのメモ帳でもあります。そのためにcssやhtmlを使用して意味のあるまとまりにできたらなと思います。
また、コメントや疑問がありましたら、気軽にお願いします。人見知りかつ一人が気楽でしたが、いろんな人と交流し楽しく成長できるようにがんばります。
github
Twitter
cloudControl