Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index: version (Lumen 5.2 + dingo) #924

Closed
lebanonsky opened this issue Mar 22, 2016 · 1 comment
Closed

Undefined index: version (Lumen 5.2 + dingo) #924

lebanonsky opened this issue Mar 22, 2016 · 1 comment

Comments

@lebanonsky
Copy link

@lebanonsky lebanonsky commented Mar 22, 2016

Tried to setup a simple app accoriding to the wiki but got stuck in routes and getting this error:
Undefined index: version

in Router.php line 415
at Application->Laravel\Lumen\Concerns\{closure}('8', 'Undefined index: version', '/home/leban/sirkka/vendor/dingo/api/src/Routing/Router.php', '415', array('methods' => array('GET', 'HEAD'), 'uri' => '/', 'action' => array(object(Closure), 'namespace' => null, 'prefix' => '', 'middleware' => array(), 'providers' => array(), 'scopes' => array(), 'before' => array(), 'after' => array(), 'where' => array(), 'uri' => '/'))) in Router.php line 415
at Router->addRoute(array('GET', 'HEAD'), '/', object(Closure)) in Router.php line 188
at Router->get('/', object(Closure)) in routes.php line 20
at require('/home/leban/sirkka/app/Http/routes.php') in app.php line 98
at {closure}(object(Application))
at call_user_func(object(Closure), object(Application)) in RoutesRequests.php line 92
at Application->group(array('namespace' => 'App\Http\Controllers'), object(Closure)) in app.php line 99
at require('/home/leban/sirkka/bootstrap/app.php') in index.php line 14

Here is my routes.php:

$api = app('Dingo\Api\Routing\Router');
$api->get('/', function () use ($api) {
    return $api->version();
    });
$api->version('v1', [], function ($api) {
    $api->get('esiintyja/{id}', function ($id) {
               //
    });
}); 

Can anyone point me to a right direction whether my problem is my environment or code?

@jasonlewis
Copy link
Contributor

@jasonlewis jasonlewis commented Mar 23, 2016

Your routes file should look more like this.

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

$api->version('v1', function ($api) {
    $api->get('/', function () use ($api) {
        return $api->version(); // not sure what you wanted to do here but this isn't valid...
    });

    $api->get('esiintyja/{id}', function ($id) {
               //
    });
});

Loading

@jasonlewis jasonlewis closed this Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants