Laravel 5和Illuminate/html [英] Laravel 5 and Illuminate/html
问题描述
我正在尝试在项目中使用{{ HTML }}
,但是遇到了一些错误.我在互联网上研究了该问题,并且我相信我在做正确的步骤,但是,在尝试加载我的母版页时,我仍然遇到相同的错误.
I am trying to use {{ HTML }}
in my project however I am running into several errors. I researched on internet about the problem, and I believe I am doing the right steps, however, I keep falling in the same error while I am trying to load my master page.
FatalErrorException在...第9行:未找到类'HTML'
FatalErrorException in ... line 9: Class 'HTML' not found
所以我做的是:
-
编辑
composer.json
文件并在require {}
运行composer update
(一切似乎都很好)
Run composer update
(everything seems fine)
已添加:
providers => 'Illuminate\Html\HtmlServiceProvider',
以及
`aliasses =>
'Form' => 'Illuminate\Html\FormFacade',
'Html' => 'Illuminate\Html\HtmlFacade',
(即使已经放在别名和提供者下面的那些如下,看来我添加的那些看起来与其余的完全不同:
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
'Illuminate\Html\HtmlServiceProvider', // The one I added
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Form' => 'Illuminate\Html\FormFacade', // I added
'Html' => 'Illuminate\Html\HtmlFacade', // I added
这是我的master.blade.php
的代码段版本:
And here is the snippet version of my master.blade.php
:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset = "UTF-8">
<title></title>
{{ HTML::script('js/jquery.js') }} // Line 9
{{ HTML::script('js/bootstrap.js') }} // Line 10
{{ HTML::style('css/bootstrap.js') }} // Line 11
</head>
我得到的错误是:
#p#第9行中的FatalErrorException: 找不到类"HTML" 在
FatalErrorException in ### line 9: Class 'HTML' not found in
/Applications/MAMP/htdocs/laratest/storage/framework/views/###第9行
/Applications/MAMP/htdocs/laratest/storage/framework/views/### line 9
我从诸如这本YouTube上的教程中受益和已解决的标签问题,该问题正在解决相同的问题,但在我的情况下并未解决该问题.
I was benefiting from several tutorials such as This one on YouTube and Laracast. I also found a Solved-tagged question which is addressing the same issue but did not fix the issue in my case.
同样更改为{!! HTML !!}
也不起作用
Also changing to {!! HTML !!}
is not working either
推荐答案
Illuminate/HTML包已弃用
使用:laravelcollective/html
composer require laravelcollective/html
将此行添加到config/app.php
Add this lines in config/app.php
在提供商组中:
Collective\Html\HtmlServiceProvider::class,
在别名组中:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
这篇关于Laravel 5和Illuminate/html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!