I'm trying to make a REST API using FOSRestBundle and I'm getting some errors due to routing. This is how I test the routes. With this code in routing.yml
I get this error:
1st test:
routing.yml
device_id_api:
type: rest
path: /device/{imei}/getid
resource: "Device\DeviceBundle\Controller\DeviceRestController"
Error
FileLoaderLoadException: Cannot import resource "/var/www/html/src/Device/DeviceBundle/Resources/config/routing.yml" from "/var/www/html/app/config/routing.yml". (The routing file "/var/www/html/src/Device/DeviceBundle/Resources/config/routing.yml" must not specify both the "resource" key and the "path" key for "device_id_api". Choose between an import and a route definition.)
2nd test:
`routing.yml
device_id_api:
type: rest
prefix: /device/{imei}/getid
resource: "TaxiBooking\Device\DeviceBundle\Controller\DeviceRestController"
Error
No route found for "GET /device/2147483647/getid"
What is wrong on that routes? I clear the cache several times and the error remains. Any help?
The prefix /device/{imei}/getid
is exactly that, a prefix.
The actions in your controller like (for, example) getUsersAction
will then be added to this prefix to create paths like /device/{imei}/getid/users [GET]
.
It's all explained in the docs minus your usage of the prefix, but that just means that it added to the start of the path auto-generated by the RoutingLoader.