Search code examples
laravellaravel-5laravel-facade

Method open does not exist, Laravel, Form facade


I am learning laravel following a tutorial. I am stuck with this error

ErrorException in Macroable.php line 81: Method open does not exist. (View: path\to\project\resources\views\form.blade.php)

I am using FormFacade. earlier I was facing an error saying: Call to undefined method Illuminate\Foundation\Application::bindShared()

which I overcame by replacing bindShared with singleton all over the file

/path/project/vendor/illuminate/html/HtmlServiceProvider.php

form.blade.php

<html>


    <head>
        <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
    </head>

    <body>
        <h1>Create a new form</h1>
        <hr/>

        {{ Form::open() }}



        {{ Form::close() }}
    </body>


</html>

HtmlServiceProvider.php

use Illuminate\Support\ServiceProvider;

class HtmlServiceProvider extends ServiceProvider {

    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = true;

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->registerHtmlBuilder();

        $this->registerFormBuilder();

        $this->app->alias('html', 'Illuminate\Html\HtmlBuilder');
        $this->app->alias('form', 'Illuminate\Html\FormBuilder');
    }

    /**
     * Register the HTML builder instance.
     *
     * @return void
     */
    protected function registerHtmlBuilder()
    {
        $this->app->singleton('html', function($app)
        {
            return new HtmlBuilder($app['url']);
        });
    }

    /**
     * Register the form builder instance.
     *
     * @return void
     */
    protected function registerFormBuilder()
    {
        $this->app->singleton('form', function($app)
        {
            $form = new FormBuilder($app['html'], $app['url'], $app['session.store']->getToken());

            return $form->setSessionStore($app['session.store']);
        });
    }

    /**
     * Get the services provided by the provider.
     *
     * @return array
     */
    public function provides()
    {
        return array('html', 'form');
    }

}

Plese Help.


Solution

  • illuminate/html was deprecated for Laravel 5.0, and has not been updated to work with Laravel 5.1+.

    You need to replace it with the laravelcollective/html package.