Search code examples
phpsymfonyfosrestbundle

FOSRestBundle Annotations for GET


I am currently developing an API and am using FOSRestBundle. I've gone wrong somewhere with the annotation side of my controller.

Please see my code below:

use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\FOSRestController;

class DefaultController extends FOSRestController
{
    /**
     * @Rest\("/default/{string})
     * @param string $string
     */
    public function defaultAction($string)
    {}
}

I am trying to to pass a parameter to the default action and do something with it. However, the parameter I include in the URL isn't getting passed to the action. Any help will be appreciated.


Solution

  • You're just missing the Get from your first annotation, it should be: @Rest\Get("/default/{string}")