我使用 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 项目”。消息,并且没有记录配置错误。