Reputation: 1272
I'm using PhpStorm 2019.2.1 to develop Laravel applications. I switched to this version from 9.3 and now it recognizes controller methods and classes as unused. (and provides quick fixes which doesn't help)
What might be the reason for that and how can I solve this?
Upvotes: 3
Views: 2845
Reputation: 129
You can use PHPDoc @uses in your /routes/web.php
/**
* @uses App\Http\Controllers\SomeController::SomeMethod
*/
Route::get('/someRoute', 'SomeController@SomeMethod');
Upvotes: 8
Reputation: 11044
PhpStorm uses an indexer that looks for calls of your Controller classes and methods, it doesn't recognize the routing second argument because it's a string
Route::get('/someRoute', 'SomeController@SomeMethod');
While you can in theory make the controller class and methods static and call them like so
Route::resource('stuff', StuffController::class);
and
Route::get('/someRoute', SomeController::SomeMethod);
But it's better to either ignore or suppress those warnings
Upvotes: 1