Search code examples
formslaravelfacadelaravelcollective

Call to undefined method Collective


I'm new in laravel and i have some problems with installation of collective Laravel, Despite i folow the collectiveLaravel's instalation Tutorial correctely.

FatalErrorException in Facade.php line 217:
Call to undefined method Collective\Html\FormFacade::open()

In all version (5.1, 5.2, 5.3 ) that i installe, i have the same errore when calling form class in my sourcecode :

 {!! Form::open(['url' => 'foo/bar']) !!}
    some code
{!! Form::close() !!}

Tks for helping me.


Solution

  • Form and HTML facade was removed from the default installation in Laravel 5. You now need to include it yourself.

    You need to grab https://packagist.org/packages/laravelcollective/html and add Collective\Html\HtmlServiceProvider::class to your providers array. See https://laravelcollective.com/docs/5.3/html#installation for more details.


    Run composer require in your console.

    composer require "laravelcollective/html":"^5.3.0"
    

    Then add the provider to your providers array in config/app.php.

    'providers' => [
        // ...
        Collective\Html\HtmlServiceProvider::class,
        // ...
    ],
    

    Then add your aliases in config/app.php.

    'aliases' => [
        // ...
          'Form' => Collective\Html\FormFacade::class,
          'Html' => Collective\Html\HtmlFacade::class,
        // ...
    ],