Routing 使用SensioFrameworkExtraBundle@Security&;时遇到问题@在Symfony 2.8中授予

Routing 使用SensioFrameworkExtraBundle@Security&;时遇到问题@在Symfony 2.8中授予,routing,symfony-2.8,Routing,Symfony 2.8,所以我想要实现一个功能,它可以检查特定角色是否可以访问路由(url)或者不使用SensioFrameworkExtraBundle@Security&@从这里授权 我用的是symfony2.8 问题是当我在我的控制器中添加IsPermited时,我收到了这个错误消息 [语义错误]AppBundle\Controller\ProductController::newAction()方法中的批注“@Sensio\Bundle\FrameworkExtraBundle\Configuration\Is

所以我想要实现一个功能,它可以检查特定角色是否可以访问路由(url)或者不使用SensioFrameworkExtraBundle@Security&@从这里授权

我用的是symfony2.8

问题是当我在我的控制器中添加IsPermited时,我收到了这个错误消息

[语义错误]AppBundle\Controller\ProductController::newAction()方法中的批注“@Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGrated”不存在,或者无法在/home/lavin/mini project/src/AppBundle/Controller/(正在从“/home/lavin/mini project/app/config/routing.yml”导入)中自动加载

所以我尝试在stack overflow中搜索一些打开的案例,但在其他线程中的一些答案仍然让我困惑,无法像这个线程那样解决这个问题

这个呢

这是我的控制器代码

<?php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use AppBundle\Entity\Product;
use AppBundle\Entity\Category;
use AppBundle\Entity\Cart;
use AppBundle\Entity\CartProduct;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;

class ProductController extends Controller
{
    /**
     * @Route("/home")
     */
    public function homeAction()
    {
        return $this->render('product/home.html.twig');
    }
    /**
     * @Route("/", name="homepage")
     */
    public function indexAction(Request $request)
    {
        // replace this example code with whatever you need
        return $this->render('default/index.html.twig', array(
            'base_dir' => realpath($this->container->getParameter('kernel.root_dir').'/..').DIRECTORY_SEPARATOR,
        ));
    }

    /**
     * @Route("product/new", name="product_new")
     * 
     * @IsGranted("ROLE_SELLER")
     */
    public function newAction(Request $request)