Laravel Error Message Call to undefined method Collective\Html\Formfacade::open()

Posted on

This is an article where an error generated as specified in the title “Call to undefined method Collective\Html\Formfacade::open()”. This error specifically exist whenever the execution of a blade view template file which is called or rendered upon accessing a web-based application using Laravel framework through URL which has been defined in a file named routes/web.php on Laravel 5.3.

To be more detail, it happens when a blade view template defines a Form as follows :


It is actually defining a form which is going to process anything exist in a form and submitted in the URL specified as ‘test/store’. But an error suddenly is triggered as shown in the title of this article, ‘Call to undefined method Collective\Html\FormFacade::open()’ as shown in the following image :

Another prove which can support the error generated is by looking at the log file normally located ‘storage/logs/laravel.log’ as shown below :

[2017-04-27 16:03:04] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Form' not found in /var/www/html/testing/laravel-project/storage/framework/views/1477d74ed42c692c2aec30f10a974a7afa3a2b84.php:24
Stack trace:
#0 /var/www/html/testing/laravel-project/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(42): include()
#1 /var/www/html/testing/laravel-project/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(59): Illuminate\View\Engines\PhpEngine->evaluatePath('/var/www/html/t...', Array)
#2 /var/www/html/testing/laravel-project/vendor/laravel/framework/src/Illuminate/View/View.php(149): Illuminate\View\Engines\CompilerEngine->get('/var/www/html/t...', Array)
#3 /var/www/html/testing/laravel-project/vendor/laravel/framework/src/Illuminate/View/View.php(120): Illuminate\View\View->getContents()
#4 /var/www/html/testing/laravel-project/vendor/laravel/framework/src/Illuminate/View/View.php(85): Illuminate\View\View->renderContents()
#5 /var/www/html/testing/laravel-project/vendor/laravel/framework/src/Illuminate/Http/Response.php(45): Illuminate\View\View->render()
#6 /var/www/html/testing/laravel-project/vendor/symfony/http-foundation/Response.php(201): Illuminate\Http\Response->setContent(Object(Illuminate\View\View))
#7 /var/www/html/testing/laravel-project/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1028): Symfony\Component\HttpFoundation\Response->__construct(Object(Illuminate\View\View))
#8 /var/www/html/testing/laravel-project/vendor/laravel/framework/src/Illuminate/Routing/Router.php(653): Illuminate\Routing\Router->prepareResponse(Object(Illuminate\Http\Request), Object(Illuminate\View\View))

Precisely, to solve the problem, defining the {{Form}} in a blade view template will need to import FormFacade class. To solve it, there is a need for installing another package which contains FormFacade class. That package is ‘laravelcollective/html’. To be able to install it, there are several ways and steps to do it which is shown as follows :

1. Defining it into the file named ‘composer.json’ located in the root folder of Laravel framework based web application as shown below :

    "require": {
        "php": ">=5.6.4",
        "laravel/framework": "5.3.*",
        "laravelcollective/html": "5.3.*"

By adding the following line :

"laravelcollective/html": "5.3.*"

It will then informing composer to install laravelcollective/html with the version 5.3.* with the following command executed in the root folder of Laravel framework based web application with the help of  composer utility. Don’t forget to execute it in the root folder of the Laravel framework based web application :

user@hostname:/var/www/html/testing/laravel-project$ composer update

2. If the above command execution ends in failure after defining the necessary package in composer.json, there is another feature which can be used which is still using the same composer utility as shown below. Just execute the following command in the bash prompt and the main point is to execute the command exactly in the root folder of the Laravel framework-based web application as shown below :

user@hostname:/var/www/html/testing/laravel-project$ composer require "laravelcollective/html":"5.3.*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing laravelcollective/html (v5.3.1): Downloading (100%)         
Package illuminate/html is abandoned, you should avoid using it. Use laravelcollective/html instead.
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
The compiled class file has been removed.

 After successfully executed the above command, try to execute the script again containing Form class.

One thought on “Laravel Error Message Call to undefined method Collective\Html\Formfacade::open()

Leave a Reply