Laravel踩坑筆記——illuminate/html被拋棄

原由php

在使用以下代碼的時候發生報錯html

{!! Form::open() !!}

  錯誤信息laravel

[Symfony\Component\Debug\Exception\FatalErrorException]

Call to undefined method Illuminate\Foundation\Application::bindShared()

緣由app

在Stack Overflow找到相關問題(Call to undefined method Illuminate\Foundation\Application::bindShared()composer

由你們的回答和官方文檔(Upgrade Guide)中能夠知道,bindShared已經被拋棄ide

 

The actual issue is that L 5.1 has depreciated bindShared and illuminate still uses it. From the L5 upgrade page: The service container's 
bindShared method has been deprecated in favor of the singleton method. --panthro

  

解決ui

打開config/app.phpspa

移除如下句orm

providers中的
'Illuminate\Html\HtmlServiceProvider'

aliases中的
'Form'      => 'Illuminate\Html\FormFacade',
'HTML'      => 'Illuminate\Html\HtmlFacade

移除illuminate/htmlhtm

composer remove illuminate/html
composer update

從官方文檔咱們能夠看到,代替的包爲laravelcollective/html

 

因此

安裝laravelcollective/html

composer require laravelcollective/html

回到config/app.php

 加入以下語句

providers中的
Collective\Html\HtmlServiceProvider::class,

aliases中的
'Form'=>Collective\Html\FormFacade::class,
'Html'=>Collective\Html\HtmlFacade::class,

  問題解決

另外

1.本文寫做時使用Laravel版本5.4,PHP版本5.6

2.附上Laravel關於Forms & HTML的文檔(基於5.4)——laravelcollective/html