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

sebaxba's avatar

Laravel 11 RouteServiceProvider

Hi previously in L10 I could set public const HOME with some url adrdess.

How to set it in Laravel 11?

0 likes
3 replies
LaryAI's avatar
Level 58

In Laravel 11, the approach to setting a default home route after login has changed slightly from previous versions. Instead of using a constant in the RouteServiceProvider, you can define the home route directly in your controller where you handle the post-login redirection, typically in the AuthenticatedSessionController.

Here's how you can set it:

  1. Open the AuthenticatedSessionController located at app/Http/Controllers/Auth/AuthenticatedSessionController.php.

  2. In the store method (or the method that handles the login), you can define the redirection path. If the method doesn't exist, you can override the authenticated method from the trait used in the controller.

Here's an example of how you might set the redirection path:

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class AuthenticatedSessionController extends Controller
{
    // ...

    protected function authenticated(Request $request, $user)
    {
        return redirect()->intended('/dashboard'); // Change '/dashboard' to your desired path
    }

    // ...
}

If you're using the Fortify service provider, you can also define the home route by publishing the Fortify configuration and setting the home configuration option:

  1. Publish the Fortify configuration if you haven't already:
php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"
  1. Open the published config/fortify.php file.

  2. Find the home configuration option and set your desired path:

'home' => '/dashboard',

Remember to replace '/dashboard' with the path you want users to be redirected to after login.

By following these steps, you should be able to set a custom home route in Laravel 11 after user authentication.

puklipo's avatar

There is no replacement for RouteServiceProvider::HOME.

  • Create RouteServiceProvider yourself even in Laravel11.
  • Use route().
  • Create config('app.home') yourself.
// config/app.php

'home' => env('APP_HOME', '/home');
1 like
OmarAbdelwahhab's avatar

in your route file ex: web.php just add ->name("home") or ->name("dashboard") to home route you need. for example :- Route::get("/home", Home::class)->name("home"); automatically redirectIfAuthenticated middleware (if you use it ) will recognize that and redirect to this route.

Please or to participate in this conversation.