在 Laravel 中添加 HTML 和表单后出错


Error after adding HTML and Forms in Laravel

在config/app.php文件中,我将服务提供商添加到列表中:

'Illuminate'Html'HtmlServiceProvider',

并添加了别名:

'Form'      => 'Illuminate'Html'FormFacade',
'Html'      => 'Illuminate'Html'HtmlFacade',

但我得到:

HtmlServiceProvider 中的 FatalErrorException .php第 36 行:调用未定义的方法 Illuminate''Foundation''Application::bindShared((

解决方案 1转到文件Illuminate'Foundation'Application并将bindShare替换为 singleton 。这将解决您的问题。

bindShared已更名为$app->singleton()

这将更改核心文件,建议这样做。但是,如果只是在寻找快速解决方案,这将有所帮助。但我强烈建议您遵循第二种解决方案。

解决方案 2

主要问题是因为您正在使用不再维护的包Illuminate/HTML。您可以使用Laravelcollective/HTML代替此。

首先,注释掉config/app.php.中对Illuminate'Html的引用

接下来,做作曲家删除illuminate/html

之后,做composer require laravelcollective/html.

现在取消注释config/app.php文件中的Illuminate'Html项,并更新对Collective'Html而不是Illuminate'Html的引用。

我认为您应该按照以下步骤在 laravel 5 中添加 HTML 和 FORM 类。

第一位开放的作曲家。JSON 文件并在"laravel/framework"之后写入以下行:"5.2.*" 最后放逗号(,(

         "laravelcollective/html": "5.2.*"
        now open command promt and type command "composer update"
        It will take some time to upgrade.
        after complete upgradation Register the service provider in config/app.php by adding the following value into the providers array:
            Collective'Html'HtmlServiceProvider::class,
        Register facades by adding these two lines in the aliases array:
         'Form' => Collective'Html'FormFacade::class,
         'Html' => Collective'Html'HtmlFacade::class,

希望这能解决您的问题。

看这篇文章
html服务提供者