Skip to content

Routing ​


Open Laravel | Route Search and enter a route name or part of its URL. Results show the HTTP methods, URL, and route name. Select a result to navigate to its declaration.

Available Completions ​

php
// Middleware completion
Route::middleware('auth')
    // Namespace completion
    ->namespace('App\Http\Controllers')
    ->group(function () {
        // Single action controller completion
        Route::get('/profile', 'EditProfileController')->name('profile.edit');
        // Controller and action completion
        Route::delete('/profile', 'ProfileController@destroy')->name('profile.destroy');
    });
    
// Namespace completion
Route::patch('/profile', 'App\Http\Controllers\ProfileController@update')
    // Middleware completion
    ->middleware('auth')
    ->name('profile.update');

// only / except for route resource completion
Route::resource('posts', PostController::class)->only([
    'index',
    'show',
]);

// Route name completion
route('profile.edit');

INFO

PhpStorm Refactoring, Find Usages and Go to Declaration features also work with controller class and method names.

WARNING

Refactoring for route names is unavailable for now.

Route hints ​

Controller methods show the routes that point to them, with HTTP methods, URL, and route name. Click a hint to go to the route declaration, open the URL in a browser, create an .http request, or copy the URL. Cmd/Ctrl-click a hint to go straight to the route declaration. In route files, the full URL is shown at the end of each Route::get() and similar call, with the same actions.

The hints can be turned off in Settings | Languages & Frameworks | Laravel Idea | Routing.

Route files recognition ​

Laravel Idea analyzes RouteServiceProvider for Laravel (bootstrap/app.php file for Lumen) and tries to find all needed information about route files there:

  • route files
  • root namespaces
  • route name prefixes
  • etc.

For some complex cases when route files are included in a non-standard way, for example from the then: callback of withRouting() in bootstrap/app.php, add helper phpDoc comments to the included route file to get the same completions: