5

我正在尝试使用 symfony2 中的注释来定义我的路线。我的 Bundle 名称是 PatentBundle。但我收到一个错误

No route found for "GET /portfolio/

我的 app/config/routing.yml

MunichInnovationGroupPatentBundle:
resource: "@MunichInnovationGroupPatentBundle/Controller/"
type:     annotation
prefix:   /
defaults:  { _controller: "MunichInnovationGroupPatentBundle:Default:index" }

我的投资组合控制器看起来像

<?php
 namespace MunichInnovationGroup\PatentBundle\Controller;

 use MunichInnovationGroup\PatentBundle\Entity\Log;

 use MunichInnovationGroup\PatentBundle\Entity\UserPatent;
 use Symfony\Component\HttpFoundation\Response;
 use Symfony\Component\HttpFoundation\Request;
 use JMS\SecurityExtraBundle\Annotation\Secure;
 use Symfony\Component\Security\Core\Exception\AccessDeniedException;
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
 use MunichInnovationGroup\PatentBundle\Entity\SvPatents;
 use MunichInnovationGroup\PatentBundle\Entity\PmPortfolios;
 use MunichInnovationGroup\PatentBundle\Entity\UmUsers;
 use MunichInnovationGroup\PatentBundle\Form\PatentType;
 use MunichInnovationGroup\PatentBundle\Entity\PmPatentgroups;
 use Symfony\Component\Security\Core\SecurityContext;
 use MunichInnovationGroup\PatentBundle\Util\SecurityHelper;
 use Exception;

/**
 * Portfolio controller.
 * @Route("/portfolio")
*/
class PortfolioController extends Controller {

/**
 * Index action.
 *
 * @Route("/", name="portfolio")
 * @Method({"GET", "POST"})
 * @Template("MunichInnovationGroupBundle:Portfolio:show.html.twig")
 */
public function indexAction(Request $request) {
      // method code goes here
    }
4

3 回答 3

9
# app/config/routing.yml

MunichInnovationGroupPatentBundle:

    resource: "@MunichInnovationGroupPatentBundle/Controller/DefaultController.php"
    type:     annotation
    prefix:   /

控制器应具有:

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
于 2012-06-16T16:27:49.870 回答
1

如果您在开发环境中,请检查您在 routing_dev.yml 中导入 routing.yml:

# app/config/routing_dev.yml

_main:
    resource: routing.yml
于 2012-06-16T16:39:22.520 回答
-2

在您的捆绑包中添加以下代码MunichInnovationGroup/PatentBundle/Resources/config/routing.yml

_admin_emailTemplate:
    pattern: admin/emailTemplate
    defaults: {_controller: DashboardEmailTemplateBundle:Default:index }
requirements: { _method: GET | POST }

以上只是捆绑的一个例子。您只需发布粗体文本“要求”。

于 2013-09-19T05:06:21.733 回答