2

Have a fresh install of Lumen 5.2 and new install of Dingo 1.0.*@dev

I have installed the service provided in bootstrap/app.php

Also setup .env file eg

API_VERSION=v1
API_PREFIX=api
API_SUBTYPE=app
API_DEBUG=true

In the Http/routes.php I have added a test route eg

$api = app('Dingo\Api\Routing\Router');


$api->version('v1', ['namespace' => 'App\Http\Controllers\V1'], function ($api) {
    $api->get('example', 'ExampleController@test');
});

This route is not working plus in command line if I try php artisan api:routes

I get error

[Symfony\Component\Console\Exception\CommandNotFoundException]  
  Command "api:routes" is not defined.                            
  Did you mean this?                                              
      api:docs  

Have I missed something? Also using HTTP Basic if it helps?

Lee
  • 20,034
  • 23
  • 75
  • 102

3 Answers3

5

In Dingo Documentation -> Creating API Endpoints section you can find this sentence:

"If you're using Laravel 5.1 you can see the registered routes using Artisan.

$ php artisan api:routes

"

If you also run

$ php artisan list

only api:docs is available - api:routes is missing.

That means that this command do not work in Lumen.

0

composer requires jakubkratina/lumen-dingo-route-list

Add the following code in app/Console/Kernel.php:

    protected $commands = [
        \JK\Dingo\Api\Console\Commands\RouteListCommand::class
    ];
tomerpacific
  • 4,704
  • 13
  • 34
  • 52
-1

By default, as shown in docs, lumen don't ship with api:routes. But you can use lumen-dingo-route-list from jakubkratina. It will add route:list to your artisan.

By the way, I'd to do some adjustments to get it working:

First, include the backlash into the registration

    protected $commands = [
        \JK\Dingo\Api\Console\Commands\RouteListCommand::class
    ];

And last, edit vendor/jakubkratina/lumen-dingo-route-list/src/RouteListCommand.php and add this code:

public function handle()
{
    return $this->fire();
}
Gardner
  • 112
  • 12