composer.phar を使用して Symfony 2.2.1 標準版をインストールし、app/console ユーティリティを使用して「ClientBundle」を生成しました。
@Route アノテーションを使用してルートを定義しようとしています。これが私のコントローラーです:
namespace ScrumBoard\ClientBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
/**
* @Route("/my/route/path")
*/
public function indexAction($name)
{
return $this->render('ScrumBoardClientBundle:Default:index.html.twig', array('name' => $name));
}
}
そして、私のバンドルは次のように定義されています:
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\AopBundle\JMSAopBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
new Acme\HelloBundle\AcmeHelloBundle(),
new ScrumBoard\ClientBundle\ScrumBoardClientBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
SensioFrameworkExtraBundle がバンドルのリストに含まれていることがわかります。
ただし、http://symfony2.localhost/app_dev.php/my/route/pathに行くと、
ERROR - Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /my/route/path"" at C:\webdev\scrum-whiteboard\symfony-quickstart\app\cache\dev\classes.php line 3609
だから、明らかに何かが欠けています... @Route アノテーションを機能させるにはどうすればよいですか?
JFYI、http://symfony2.localhost/config.phpにアクセスすると、Symfony2 が動作していることがわかります。「新しい Symfony プロジェクトへようこそ」というメッセージが表示されます。メッセージが表示され、構成エラーは記録されません。