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

kossa's avatar
Level 20

Route::parameters() not working on Laravel 11

Hello,

I'm upgrading Laravel 10 to 11, I'm getting error Route::parameters(), seems like it was deleted, any alternative?

0 likes
4 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

In Laravel 11, if Route::parameters() has been removed or is not functioning as expected, you can use an alternative approach to access route parameters within your application. Laravel provides several ways to access route parameters, both globally and within specific contexts.

Here's an alternative approach using route model binding and accessing parameters directly in the controller methods:

// In your routes/web.php or routes/api.php

use App\Http\Controllers\YourController;

Route::get('/your-route/{parameter}', [YourController::class, 'yourMethod']);

// In your App\Http\Controllers\YourController

public function yourMethod($parameter)
{
    // You can access the parameter directly
    // Do something with $parameter
}

If you need to access the route parameters globally, you can use the request() helper function or the Request facade:

use Illuminate\Support\Facades\Request;

// Anywhere in your application
$parameters = Request::route()->parameters();

// Or using the helper function
$parameters = request()->route()->parameters();

These methods should provide you with the necessary functionality to access route parameters in Laravel 11. Remember to check the official Laravel documentation or upgrade guide for any additional changes that may affect how you access route parameters in the new version.

kossa's avatar
Level 20

@puklipo My issue was with middleware, I used $middleware->append([ ..., I fixed it by $middleware->appendToGroup('web', [ ...

Please or to participate in this conversation.