Laravel 调用未定义的方法 Illuminate\Html\HtmlServiceProvider::style()`

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32139171/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:13:56  来源:igfitidea点击:

Laravel Call to undefined method Illuminate\Html\HtmlServiceProvider::style()`

phplaravellaravel-5blade

提问by cow

I'm using the laravel 5.1 framework on my centos6 host. I already used composer install illuminate/html, but calling HTML::style()results in this error: FatalErrorException in 7b06fa36a7460c71e5daf57645a3dbda line 12: Call to undefined method Illuminate\Html\HtmlServiceProvider::style()

我在我的 centos6 主机上使用 laravel 5.1 框架。我已经使用过 composer install illuminate/html,但调用会HTML::style()导致此错误:FatalErrorException in 7b06fa36a7460c71e5daf57645a3dbda line 12: Call to undefined method Illuminate\Html\HtmlServiceProvider::style()

My app config :

我的应用程序配置:

'aliases' => [
    //more...
    'HTML' => Illuminate\Html\HtmlServiceProvider::class,
    'Form' => Illuminate\Html\FormFacade::class
],

'providers' => [
    //more...
    Illuminate\View\ViewServiceProvider::class,
    Illuminate\Html\HtmlServiceProvider::class,
]

composer.json:

作曲家.json:

  "require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*",
    "illuminate/html": "5.*"
},

Such as {!! Form::open() !!} ...is well except HTML::style().

{!! Form::open() !!} ...非常除HTML::style()

What should I do?

我该怎么办?

回答by jedrzej.kurylo

You have aliased invalid class.

您为无效类设置了别名。

Replace

代替

'HTML' => Illuminate\Html\HtmlServiceProvider::class,

with

'HTML' => Illuminate\Html\HtmlFacade::class,

回答by Lara Gallassi

terminal

终端

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

Next, add your new provider to the providers array of config/app.php:

接下来,将您的新提供程序添加到 config/app.php 的 providers 数组中:

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

Finally, add two class aliases to the aliases array of config/app.php:

最后,在 config/app.php 的 aliases 数组中添加两个类别名:

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

回答by John Smith

If using Laravel 5 these have been moved and are now depreciated, and are no longer in the core. They are now part of the Laravel Collective Read here for what you should be using, and how to intall

如果使用 Laravel 5,这些已经被移动并且现在被贬值,并且不再在核心中。它们现在是 Laravel 集体的一部分,请阅读此处了解您应该使用的内容以及如何安装

https://laravelcollective.com/docs/5.2/html

https://laravelcollective.com/docs/5.2/html