I prefer to use vscode for the laravel project.
I am a beginner and recently I got work on a company project. so I need to clone the project. but I am getting a class error in my vscode but the project running perfectly.
I can solve the error by importing class by importing Illuminate\Support\Facades\ClassName.
The problem is I have to go into each file and Import the required class in my PHP file. that is not ok.
I am using PHP intelephence extension for the autosuggestion. if I disable the intelephence I am not getting this class error. but not getting auto-completion.
How can I deal with this issue?.
Give me some suggestions and solutions to deal with these issues.
Thanks in advance.
CodePudding user response:
I think you have to import individually because the plugin will not resolve the imports in cases where there are conflicts i.e., classes, interfaces having the same name.
Even if it does resolve, the project is prone to have issues, which will be hard to debug at times.
e.g., same class and interface name
Note: Always import things at the beginning of the file instead of accessing it in the functions multiple times. By doing so, you can alias different imports.
Import shortcut for vs code place the cursor on the thing to import and Press CTRL ALT i on Windows / CTRL Option i on MacOS.
CodePudding user response:
I recommend these awesome extensions, these will help you more
Please note that there are some errors that VS Code generates because VS Code not intelligence to much to know that these classes or methods are exists So, you can use @see
and @method
to resolve these errors