How to RouteServiceProvider Configuration in Larevl 11?




How to RouteServiceProvider Configuration in Larevl 11?

Hi, Dev

In Laravel 11, the RouteServiceProvider.php file has been removed. Instead, you can now configure routes directly in the app.php file.

You might wonder how to create a custom route file without the RouteServiceProvider. In versions prior to Laravel 11, you would use the RouteServiceProvider.php file for this purpose. However, Laravel 11 introduces the option to define custom route files directly in the app.php file, allowing you to customize routes from there.

Before Laravel 11, you would define a custom route file like this:


public function boot()


$this->routes(function () {






Now, In Laravel 11 Version, You can define custom route file like the following way:



use Illuminate\Foundation\Application;

use Illuminate\Foundation\Configuration\Exceptions;

use Illuminate\Foundation\Configuration\Middleware;

use Illuminate\Support\Facades\Route;

return Application::configure(basePath: dirname(__DIR__))


web: __DIR__.'/../routes/web.php',

commands: __DIR__.'/../routes/console.php',

channels: __DIR__.'/../routes/channels.php',

health: '/up',

then: function () {






->withMiddleware(function (Middleware $middleware) {



->withExceptions(function (Exceptions $exceptions) {



Next, you need to create custom admin.php file like the following way:



use Illuminate\Support\Facades\Route;

Route::get('/dashboard', [App\Http\Controllers\HomeController::class, 'index']);

Route::get('/users', [App\Http\Controllers\UserController::class, 'index']);

Route::get('/posts', [App\Http\Controllers\PostController::class, 'index']);

Now, you can run the following command to see the list of routes:

php artisan route:list

You will see the following routes:


I hope it can help you...

#Laravel 11