Home > Software engineering >  Laravel Route::controller completion in PhpStorm
Laravel Route::controller completion in PhpStorm

Time:08-12

I'm looking for a solution for better code navigation within routes definition in PhpStorm.

Using "array convention":

Route::get('endpoint', [Controller::class, 'get']);
Route::put('endpoint', [Controller::class, 'put']);

I can quickly jump to get or put methods from an editor. However, I want to use Route::controller more often:

Route::controller(Controller::class)->group(function() {
  Route::get('endpoint', 'get');
  Route::put('endpoint', 'put');
});

But this solution allows me to jump to controller class only, not to methods directly.

I have enabled Laravel support in settings. PhpStorm 2022.2.

CodePudding user response:

[Controller::class, 'put'] -- this is generic PHP stuff, not linked to any framework and therefore such navigation is provided by PhpStorm core.

However using Route::controller(Controller::class) grouping is specific to Laravel. PhpStorm does not provide any Laravel-specific support (excluding Blade files). Therefore such navigation should be coming from a Laravel specific plugin.

The original Laravel plugin is no longer compatible with the 2022.2 version: the latest version was released like 3 years ago (back in 2019) and its GitHub repo is in archived/read-only state now ("This repository has been archived by the owner. It is now read-only.").

I suggest you check Laravel Idea plugin instead. It supports such navigation. Please note: it's a PAID plugin, but it is in active development, has many features (much more than the original Laravel plugin) and well worth the money for devs using Laravel framework.

  • Related