Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AtomCoder's avatar

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?

0 likes
10 replies
KalimeroMK's avatar

Just run php artisan vendor:publish and select witch provider you want to be publish and you can play with it

AtomCoder's avatar

@KalimeroMK Thanks for your response.

Just tried that, but the RouteServiceProvider is not available to be published.

puklipo's avatar

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');
});
1 like
Jaber67's avatar

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',
1 like
Jeffsouza19's avatar

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: ''
   )
2 likes

Please or to participate in this conversation.