I have just installed Dingo and it appear to work with the following URL:
http://website.dev/api/test
http://website.dev/api/hello
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
$api->get('test', function () {
return 'Test';
});
$api->get('hello', function () {
return 'Hello';
});
});
I would like version v1 to be included in the URL, how do I get this to work? When I try:
http://website.dev/api/v1/test
I get error:
{
"message": "404 Not Found",
"status_code": 404
}
In the .env
file, I have: API_PREFIX=api
According to Dingo Configuration:
Avoid putting a version number as your prefix or subdomain as versioning is handled via the Accept header.
The version of dingoAPI don't work this way. Because they aren't versioning the API in the URI, you need to define an Accept header to request a specific version. The header is formatted like so:
Accept: application/vnd.YOUR_SUBTYPE.v1+json
For accessing the version you will need a HTTP Client like postman
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With