Skip to content
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

[5.7] Make route group namespaces absolute if they start with '\' #23113

Merged
merged 1 commit into from
Feb 14, 2018
Merged

[5.7] Make route group namespaces absolute if they start with '\' #23113

merged 1 commit into from
Feb 14, 2018

Conversation

Jack97
Copy link
Contributor

@Jack97 Jack97 commented Feb 10, 2018

Clone of #23066 - Pushing to the master branch because it's a breaking change.

Currently, you can register routes to point to a fully qualified class name if it starts with a '\' - which will ignore the namespace that would otherwise be inherited from the route group stack:

Route::get('users', '\Foo\Bar\UsersController@index')

This PR adds the same functionality for route groups:

Route::namespace('App\Http\Controllers')->group(function () {
    Route::namespace('\Foo\Bar')->group(function () {
        Route::get('users', 'UsersController@index'); // Foo\Bar\UsersController@index
    });
});

An example use case for this functionality would be for route macros provided by a package. For example:

Route::macro('packageResources', function () {
    Route::namespace('\Vendor\Namespace')->group(function () {
        Route::get('resources', 'ResourcesController@index');
        // Long list of other routes.
    });
});

This means you can use the above macro in your applications main routes file without the namespace being inherited.

@GrahamCampbell GrahamCampbell changed the title Make route group namespaces absolute if they start with '\' [5.7] Make route group namespaces absolute if they start with '\' Feb 10, 2018
@taylorotwell taylorotwell merged commit b345650 into laravel:master Feb 14, 2018
@Jack97 Jack97 deleted the route_group_absolute_namespace branch February 14, 2018 07:02
@klgd
Copy link

klgd commented Jun 5, 2018

Are you planning to merge into 5.6? @taylorotwell

@GrahamCampbell
Copy link
Member

No, because this is a breaking change.

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