gpt4 book ai didi

带注释的 Symfony2 路由

转载 作者:行者123 更新时间:2023-12-02 13:57:52 24 4
gpt4 key购买 nike

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

No route found for "GET /portfolio/

我的应用程序/config/routing.yml

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

我的投资组合 Controller 看起来像

<?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
}

最佳答案

# app/config/routing.yml

MunichInnovationGroupPatentBundle:

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

Controller 应该具有:

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

关于带注释的 Symfony2 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11064902/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com