Support the ongoing development of Laravel.io →
posted 9 years ago
Requests
Last updated 2 years ago.
0

well I know some frameworks have shortcuts like this built in.. but overall laravel is supposed to make for a rapid application. You cannot compare one feature with another.. you have to compare the overall product.

There are so many features in laravel that CI doesnt have plus on top CI is still stuck in dark ages :p

0

@shez1983 Actually it's a shortcut in Laravel, but it doesn't really matter, let's forget about it :) I'd like to know what are the benefits of using Route::get/post etc for every single controller and action in comparison to Codeigniter.

And yes, I know CI is stuck in dark ages:) That's why I'm slowly learning Laravel.

0

It's a good question.

I know when Kohana started using explicit routes, it was done in the name of clarity; you can read the routes file and get a feel for the app, as well as disabling routes, or in larger applications, changing routes. Named routes in Laravel should also help to decouple routes from methods as an application grows (though I've not yet built an app big enough to warrant this). I guess one of the major use cases as well, is that it helps to stop people hacking your application - you can conditionally define routes depending on application / user state.

There's nothing to stop you writing code that maps arbitrary routes to controllers though (it's all PHP).

I use the following setup to quickly-and-dirtily route URLs to methods, specifically for testing out PHP functionality in development:

Hope that helps.

Dave.

Last updated 9 years ago.
0

The shortcut is

Route::any('blog_post')

And Laravel handles get/post data the same way using the equivalent of $_REQUEST instead of $_GET or $_POST so no matter what method you use, the data will always be accessible using get (even if the method is post):

Request::get('name')

The benefit to using post or get in your route would be more for APIs and further determining what action that should happen--effectively just another level of granularity/detail where Laravel does the (not-so in this case) heavy lifting for you. I've also found the ajax method very useful to determine if a page is being loaded into a div on a page or loaded as a standalone page.

if (Request::ajax()) { 
    //do something 
}
0

@davestewart - thanks for the link, look like this is what I was looking for, although IMHO it would be much better if it was built-in...

@jeremybalog Re: The shortcut is Route::any('blog_post')

OK, but is there any way to make a route, using any request method, and to any action, without using any external classes like the one from @dacesteward? So I could compress this to one line:

Route:any('blog/,'blogController@index');
Route:any('blog/new_post','blogController@new_post');
Route:any('blog/show_most_popular,'blogController@show_most_popular');

?

0

OK, nevermind, thank you everybody.

0

I've an updated version of that code which handles all HTTP verbs, I'll update the trick in the next day or so.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.