Laravel 11 - RouteServiceProvider Hi Guys,
I'm working on a project using Laravel 11 (Dev). I'm tring to allow users to have the ability to create their own sub-domains.
In previous versions of laravel I accessed /providers/RouteServiceProvider.php and added something like this:
Route::domain('{subdomain}.site.com')
->group(base_path('routes/subdomain.php'));
The problem I'm having is that the Laravel 11 structure has been changed and the RouteServiceProvider has been removed. How can I acheive the sub-domain routing in Laravel 11?
Just run php artisan vendor:publish and select witch provider you want to be publish and you can play with it
@KalimeroMK Thanks for your response.
Just tried that, but the RouteServiceProvider is not available to be published.
@atomcoder Why not just use Laravel 10.x and wait for 11.x to actually be finalised and released?
Just move to routes/web.php
//routes/web.php
Route::domain('{subdomain}.site.com')
->group(base_path('routes/subdomain.php'));
Route::get('/', function () {
return view('welcome');
});
You can activate api routing by uncommenting the api: parameter in the bootstrap/app.php file.
return Application::configure(basePath: dirname(__DIR__))
->withProviders()
->withRouting(
web: __DIR__.'/../routes/web.php',
// api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
you can use the apiPrefix in the bootstrap/app.php file.
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
apiPrefix: ''
)
Please sign in or create an account to participate in this conversation.