If you are looking for more automatic routing, this would be the Laravel 4 way:
Route:
Route::controller('users', 'UsersController');
Controller (in this case UsersController.php):
public function getIndex() { // routed from GET request to /users } public function getProfile() { // routed from GET request to /users/profile } public function postProfile() { // routed from POST request to /users/profile } public function getPosts($id) { // routed from GET request to: /users/posts/42 }
As mentioned in Shift Exchange, there are some advantages to doing this in the right way. In addition to the excellent article he linked, you can create a name for each route , for example:
Route::get("users", array( "as"=>"dashboard", "uses"=>" UsersController@getIndex " ));
Then, when creating URLs in your application, use the helper to create a link along the specified route :
$url = URL::route('dashboard');
Then links will be checked in the future from changes in controllers / actions.
You can also create links directly to actions that will continue to work with automatic routing.
$url = URL::action(' UsersController@getIndex ');
source share