2017-06-20 98 views
0

我創建了一個新的控制器(testController),它擴展了FOSRestController。當我運行symfony命令「debug:router」時,我看不到在此控制器中創建的路由「/ test」。隨着郵差,我有一個404錯誤...FOSRestBundle:我看不到我的新路線

我敢肯定我忘了一些東西,但我不知道是什麼。在這裏我的代碼:

testController.php

<?php 

namespace Project\ApiBundle\Controller; 

use FOS\RestBundle\Controller\Annotations; 
use FOS\RestBundle\Controller\Annotations as Rest; 
use FOS\RestBundle\Controller\Annotations\Delete; 
use FOS\RestBundle\Controller\Annotations\Get; 
use FOS\RestBundle\Controller\Annotations\Post; 
use FOS\RestBundle\Controller\Annotations\Put; 
use FOS\RestBundle\Controller\FOSRestController; 
use FOS\RestBundle\View\RouteRedirectView; 
use Nelmio\ApiDocBundle\Annotation\ApiDoc; 
use Symfony\Component\HttpFoundation\Request; 
use Symfony\Component\HttpFoundation\Response; 
use Symfony\Component\HttpFoundation\JsonResponse; 
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; 
use JMS\Serializer\SerializationContext; 

/** 
* Class testController. 
*/ 
class testController extends FOSRestController 
{ 
    /** 
    * List . 
    * @ApiDoc(
    * resource = true, 
    * statusCodes = { 
    *  200 = "Returned when successful" 
    * } 
    *) 
    * 
    * @Rest\View() 
    * @Get("/test") 
    * 
    * @param Request $request the request object 
    * 
    * @return array 
    */ 
    public function getTest(Request $request) 
    { 
     return "hello world"; 

    } 
} 

而且,在這裏我的routing.yml文件:

api_test: 
    type: rest 
    resource:  Project\ApiBundle\Controller\TestController 

什麼我忘了嗎?

非常感謝!

回答

1

我終於找到了答案...很容易,但我沒有看到它!方法名稱:

=> getTest Action