Skip to content

Allow bundles to respond to root requests. #1014

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

Merged
merged 1 commit into from
Sep 2, 2012

Conversation

jasonlewis
Copy link
Contributor

Just as the title says. This allows bundles to be registered to respond to root requests.

return array(
    'bundle' => array(
        'handles' => '/'
    )
);

If others could test this and let me know if it is working good for them that'd be great. I've tested it a bit on a bundle I'm working on and it seems to be working.

Note that named routes that are used with things such as URL::to_route(), etc, are adjusted accordingly. This means you can still use the (:bundle) placeholder in your routes.

First discussed in #876.

Signed-off-by: Jason Lewis jason.lewis1991@gmail.com

Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
@daylerees
Copy link
Contributor

I think if you Bundle::start or auto start the bundle you might be able to map route. Worth a try but adding to the test group :)

@jasonlewis
Copy link
Contributor Author

The beauty of this is that it still gives users the flexibility of using the (:bundle) placeholder in their bundle routes while allowing people who use the bundle to define a "handle" of whatever they want.

If you have a route in your application/routes.php file like this:

Route::get('/', function()
{
    return 'Hello, World';
});

Then in your bundle, say bundles/forum/routes.php you have:

Route::get('(:bundle)', function()
{
    return 'Hello, Forum';
});

When you register the forum bundle and you set the handles key to / it will overwrite the route defined in application/routes.php, thus making the bundle respond to route requests but at the same time you could have made the handles key forum.

@franzliedke was after similar functionality. :)

@franzliedke
Copy link
Contributor

Thanks for the patch.

This works and should be merged.
Nontheless it's kind of hacky. @taylorotwell Are there any improvements on routing on the horizon for L4? @ShawnMcCool had some ideas.

taylorotwell added a commit that referenced this pull request Sep 2, 2012
Allow bundles to respond to root requests.
@taylorotwell taylorotwell merged commit 0a908ef into laravel:develop Sep 2, 2012
@taylorotwell
Copy link
Member

Thanks!

zoe-edwards pushed a commit to zoe-edwards/laravel that referenced this pull request Oct 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants