Search code examples
formsphpstormlaravelcollective

LaravelCollective v6.2: Undefined class 'Form' in PhpStorm


I have just installed LaravelCollective v6.2 running $ composer require laravelcollective/html command.

I made a form:

{!! Form::open(['url' => '/posts']) !!}
        <div class="form-group">
            <label for="inputTitle"></label>
            <input type="text" class="form-control" id="inputTitle" placeholder="Enter title"
                   name="title">
        </div>
        <button type="submit" class="btn btn-primary">Submit</button>
    {!! Form::close() !!}

PhpStorm says Undefined class 'Form'. How can I fix this?

enter image description here

My composer.json:

"require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.40",
        "laravel/tinker": "^2.5",
        "laravelcollective/html": "^6.2"
    },

Solution

  • Form is a Laravel facade. Quite a bit of magic is involved here.

    Do you use Laravel IDE Helper by Barry vd. Heuvel?

    • If you do not: install and use it. It generates special .php file(s) that are used by the IDE to better understand the Laravel related code (facades and other Laravel stuff).
    • If you do: you need to re-generate the IDE helper file so it includes the Form facade.