Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jaydeluca's avatar

Dingo API and Laravel 5.3

I am working on building an API with Laravel 5.3 and Dingo API, and I am curious where I should be putting the routes now that the files are split between web/api. I would assume in the API routes file but I was having some issues and wanted to confirm.

This is the code im referring to:

$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
    ....
});
0 likes
1 reply
dashawk's avatar

You are right about putting your routes in the routes/api.php file and your declarations of the routes is also correct.

To check if your routes are registered. Type in the command php artisan api:route.

EDIT: Actually you are missing the Router Class. It should be.


$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function (Router $api) { // here
    ....
});

Please or to participate in this conversation.