3

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?

2

2 Answers 2

8

You can use PHPDoc @uses in your /routes/web.php

/**
* @uses App\Http\Controllers\SomeController::SomeMethod
*/

Route::get('/someRoute', 'SomeController@SomeMethod');
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.