Support the ongoing development of Laravel.io →
Requests Laravel.io
Last updated 1 year ago.
0

Hello Anyone having the issue?

0

Hi ! I had the same problem. I added this function to Laravel\Lumen\Application.php

/**
 * Register a resource with the application.
 *
 * @param  string  $uri
 * @param  mixed  $controller
 * @return $this
 */
public function resource($uri, $controller)
{  
    $this->get($uri, 'App\Http\Controllers\\'.$controller.'@index');
    $this->get($uri.'/create', 'App\Http\Controllers\\'.$controller.'@create');
    $this->post($uri, 'App\Http\Controllers\\'.$controller.'@store');
    $this->get($uri.'/{id}', 'App\Http\Controllers\\'.$controller.'@show');
    $this->get($uri.'/{id}/edit', 'App\Http\Controllers\\'.$controller.'@edit');
    $this->put($uri.'/{id}', 'App\Http\Controllers\\'.$controller.'@update');
    $this->patch($uri.'/{id}', 'App\Http\Controllers\\'.$controller.'@update');
    $this->delete($uri.'/{id}', 'App\Http\Controllers\\'.$controller.'@destroy');
   
    return $this;
}
0

Plus there was an existing answer to lumen routing === http://laravel.io/forum/04-25-2015-lumen-generic-controller-ro...

Last updated 8 years ago.
0

You can follow what @diegomariani did. While you're at it, check this out:

https://gist.github.com/beanmoss/977e846fee4050ae11e5

Last updated 8 years ago.
0

If you're having to go through all that you may as well just install and use Laravel.

Last updated 8 years ago.
0

@jimgwhit are you referring to the gists I gave? could you give a reason why?

0

The lumen docs shows how to route. But it's in the controllers section of the docs. If you have to keep adding tons of code to make lumen work like laravel, yek may as well use laravel. But you have good code, and your code is always useful.

0

jimgwhit said:

If you're having to go through all that you may as well just install and use Laravel.

Sorry to revive an old thread, but I keep seeing this dismissive kind of response to this question everywhere and I feel it's the kind of thinking that discourages people from trying to make something better. Resource routing is not an unreasonable wish for Lumen. Lumen is geared toward developing APIs. I actually care more about my APIs following good REST conventions than I do about apps that render HTML, most of the time. IMO Lumen ought to make it easy.

I presume that Lumen doesn't have resource routing (yet) because its router is based on FastRoute instead of Laravel's router, so work of implementing resource routing on top of it just hasn't been done yet. I bet it's achievable without a serious performance sacrifice. I'd love to see it proposed as a feature for future versions.

Thanks @diegomariani and @beanmoss for sharing your code, very handy.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

sohelamin sohelamin Joined 21 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.