laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.72k stars 11.06k forks source link

[Proposal] Defining Base URL for Route::group #181

Closed raftalks closed 11 years ago

raftalks commented 11 years ago
Route::group(array('base'=>'admin'),function(){

    Route::get('/', function()
    {
        return 'Generates: http://domain.com/admin/';
    });

    Route::get('users', function()
    {
        return 'Generates: http://domain.com/admin/users';
    });

        // generates: http://domain.com/admin/foo
    Route::get('foo', 'Namespace\FooController@method');

       // Responds to '/admin/user'
       Route::resource('user', 'Admin\\UserController');

});

I feel this might be handy when making modular app packages like a CMS module where the developer is allowed to group all the routes of the package and set its base url from the group route.

What do you think to implement this?

At the moment we can simply get similar functionality by putting a function call or string to write route url however having an option to specify a base url for grouped routes will make it nice.

cmenke commented 11 years ago

I like the idea! similar to domain-routing that is already implemented. Might also be a solution to #170.

Anahkiasen commented 11 years ago

Like this idea.

franzliedke commented 11 years ago

Exactly what we need for FluxBB. I was about to suggest this, too. (Had a browser tab open with a ticket draft, in fact.)

:+1:

taylorotwell commented 11 years ago

Done.

taylorotwell commented 11 years ago

Used prefix instead of base.

raftalks commented 11 years ago

thanks @taylorotwell :)

jasonlewis commented 11 years ago

You always come up with nicer terms @taylorotwell. base just didn't feel right yet I couldn't think of an alternative! :)

fabioneves commented 11 years ago

Excellent! I've made a question about this some days ago. http://forums.laravel.io/viewtopic.php?id=4615

Thank you Taylor