I'm using FosRestBundle
and I'm declaring a controller with manually routes.
namespace Cboujon\PropertyBundle\Controller;
use FOS\RestBundle\Controller\Annotations\QueryParam;
use FOS\RestBundle\Controller\Annotations\RouteResource;
use FOS\RestBundle\View\View;
use FOS\RestBundle\Controller\Annotations\Get;
/**
* Property controller.
* @RouteResource("Property")
*/
class PropertyRESTController extends \FOS\RestBundle\Controller\FOSRestController {
/**
*
* @return type
* @Get("/types")
*
*/
public function getTypesAction() {
...
return $this->get('fos_rest.view_handler')->handle($view);
}
}
routing.yml
cboujon_property_property_api:
resource: "@CboujonPropertyBundle/Controller/PropertyRESTController.php"
type: rest
prefix: /api
When I do the request http://localhost:8000/api/properties/types
or http://localhost:8000/api/property/types
I get
404 Not Found - NotFoundHttpException.
But if http://localhost:8000/api/types
it works!
I need to config the url http://localhost:8000/api/properties/types
. What am I doing wrong?
Update 1
There is no Property entity. PropertyController should do custom operations (No CRUD).
Update 2
You can see the git repository
RouteResource
looks like it's just to change the name (eg,FooController
using the resourceProperty
rather thanFoo
). It looks like your routing.yml should haveparent: property
in the definition for thetypes
routes. – Perduparent: property
? My other controllers defined does not need it and I didn't have any error with them. – BelfryRouteResource
annotation when you will define custom routes for all Controller actions and if you will define prefix for all actions, can use@Prefix
anotation on class controller – Thug