-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Resourceful vs restful controller routing #34
Comments
AFAIK both are still there. (just not in the documentation yet) |
@bgm Not true. |
Personally I like the old manual way of restful routing, that way I feel like I have more control over it; change as what you want; no need for "composer dump autoload". If we copy&paste or take advantage of snippets it's not such a big deal and with st2 things are much easier: https://gist.github.com/3717337 But I guess we can still go for the old way in someway, aren't we? I don't know. |
@Ktee8 Why use that snippet when you can just do something like |
Does L4 automatically generate named routes for resources like Rails? I only ask because I don't see anything in the URL class for resources, but do for actions and named routes and was wondering what's the best way to do this if we're going with 100% resourceful? |
Could it be your answer? https://github.com/daylerees/autoload-demo I'm sorry if I'm off target. |
@Ktee8 No, sorry. That issue is not directly related to this one. |
Thinking in terms of resources is inherently restful. So it's not really an issue of choosing resourceful vs. restful. When Laravel generates a full resource for you - ( |
In reference to whether L4 generates the named routes, as part of |
@niallobrien how about Route::controller('UserController','users'); |
@JeffreyWay Yes, but in Laravel 3 we could do something like get_login() and post_login() if we wanted to when $restful = true; |
Well ideally, when/if Taylor adds named route support to resourceful controller creation, then you'd do something along the lines of: $url = URL::to_route('edit_user_path', array($id)); But I guess, until then, you have to do it manually?? |
@JeffreyWay Yeah, that's what we were discussing in #laravel IRC. I think adding a URL::resource() method would be a cleaner solution, but both would work. Also, while on the topic of resources, I don't see anything there for nested resources. Might open a new issue for that. |
Hmm - I'm looking over the I thought I read something from Taylor on Twitter about implementing nested resources. Maybe not... |
Named routes: that's what I wanted to say instead of "old manual way of restful routing"; then why you need that restful snippet? 'cause I want something to refer to and change some parts as what I want; then if with Route::resource, I can make it, that's exactly what I want. Thanks. |
You don't need my restful snippet in L4. Pretty sure resourceful controllers were implemented to keep us from having to resort to big snippets like that to achieve fairly standard resource + named routes setups. |
@JeffreyWay Actually now that you say it, named routes for resources probably are the right way to go. Less things to remember (action vs named routing) and a big bonus is that people already using Meido's HTML package can still use it to generate links to resources via named routes! :) |
I support named routes for resource controllers. |
@JeffreyWay Thanks. I guess I'm beginning to see the trick. @niallobrien Sorry for a bit out of topic you intend; but some amateurs like me might benefit from it. Thank you so much. |
So something like Rails (I don't think we need '_path')? Looks nice and clean to me. |
Yeah, works for me. And then a command line option to view all the registered named routes, for convenience. Something like: php artisan routes |
@JeffreyWay That would be badass! :) |
Possibly you are getting confused with the terminology? REST by it's very design is resourceful. Rather than rattle on, take a look at this which goes into a bit of depth about API design. You will understand why the new resourceful setup is awesome :) |
@bencorlett Yes, I am aware. However, I was initially referring to L3's implementation of restful controllers when $restful = true; |
You are asking for what is Route::controller... it is your RESTfull controller from L3. Resource is like a more specific (something used in Admin a lot) RESTfull controller. |
@Robbo- Yes, I was beginning to think that. Must fully test and contribute to the docs. |
Sorry for keeping amateur questions and using wrong terminology; How about something like this?
That's from a Nettus+ Course that I'm taking now. At first I thought it's a bit different from RESTful pattern that I learned a while back; Then my wonder is if it could be achieved by Route::resource in some way easily, That's what I've been thinking and talking about here. |
Yes, the routes in Andrew's course could be modified to use L4's resourceful controllers. |
Thanks! The fact reassurances me a lot! :) |
A lot of the issues in this thread have been fixed. Closing. |
…be-passwordless laravel#13: Make user passwordless
Apply fixes from StyleCI
Update database.php
Are we switching to resourceful routing over restful routing for any particular reason?
Is there a reason why they can't both exist?
Are we worried that this will make the framework less accessible?
Thanks.
The text was updated successfully, but these errors were encountered: