skip to Main Content

My Laravel code works fine but the PHP Intelephense extension shows unnecessary error in the code. If I delete the extension, the error goes away and reappears when I reinstall it. It also shows some errors in the Laravel helpers.php folder too. My tutor uses PHPStorm and he calls the request() directly doesn’t get any errors. I mean I use VSCode and the request() works without any error but I just want to fix the squiggly error. Can anyone help me fix this issue?

Screenshot of my code

I tried uninstalling and tried again but the error doesn’t go away. Also tried configuring the settings.json file with help of chatGPT but didn’t work out either. 🙁

2

Answers


  1. In order for VS code to find the request function, it relies on the vendor/laravel/framework/composer.json file. Specificially the definition inside this block referring to the Foundation/helpers.php file.

     "autoload": {
            "files": [
                "src/Illuminate/Collections/helpers.php",
                "src/Illuminate/Events/functions.php",
                "src/Illuminate/Filesystem/functions.php",
                "src/Illuminate/Foundation/helpers.php",
                "src/Illuminate/Support/helpers.php"
            ],
            "psr-4": {
                "Illuminate\": "src/Illuminate/",
                "Illuminate\Support\": [
                    "src/Illuminate/Macroable/",
                    "src/Illuminate/Collections/",
                    "src/Illuminate/Conditionable/"
                ]
            }
        },
    

    Make sure this definition exists. if not, you can always add it to your own composer.json file.

    Login or Signup to reply.
  2. The problem here is the docblock in the request(). Almost all helpers have this problem. I think it is because of these change [11.x] feat: add more specific types and tests for helpers

    Edit #1

    If it really bothers you you can put a null value inside the request()

    request(null)->validate(...);
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search