Joe Allen
Joe Allen

Reputation: 1317

FOSRestBundle : I can't see my new route

I've created a new controller (testController) which extends FOSRestController. I can't see the route "/test" i've created in this controller when I run symfony command "debug:router". With Postman, I've a 404 error...

I'm sure I forgot something but I don't know what. Here my code :

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";

    }
}

And, here my routing.yml file :

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

What I've forgot ?

Thank you very much !

Upvotes: 0

Views: 687

Answers (1)

Joe Allen
Joe Allen

Reputation: 1317

I finally found the answer... so easy but I didn't see it ! The method name :

=> getTestAction

Upvotes: 2

Related Questions