Reputation: 12857
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 in ... line 9: Class 'HTML' not found
So what I did was:
Edited the composer.json
file and added "illuminate/html": "5.*"
under require {}
Run composer update
(everything seems fine)
Added:
providers => 'Illuminate\Html\HtmlServiceProvider',
as well as
`aliasses =>
'Form' => 'Illuminate\Html\FormFacade',
'Html' => 'Illuminate\Html\HtmlFacade',
(Even though the ones already placed under aliasses and providers are as follows which seems the ones I added looks quite different than the rest:
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
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>
The error I am getting is:
FatalErrorException in ### line 9: Class 'HTML' not found in
/Applications/MAMP/htdocs/laratest/storage/framework/views/### line 9
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.
Edit: Also changing to {!! HTML !!}
is not working either
Upvotes: 1
Views: 7289
Reputation: 371
Illuminate/HTML package has been deprecated
Use:laravelcollective/html
composer require laravelcollective/html
Add this lines in config/app.php
in providers group:
Collective\Html\HtmlServiceProvider::class,
in aliases group:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
Upvotes: 3
Reputation: 14620
First the facades aren't correct.
'Form' => 'Illuminate\Html\FormFacade', // FormFacade not HtmlFacade
'Html' => 'Illuminate\Html\HtmlFacade',
The facade is Html
not HTML
.
<!-- This won't work -->
{!! HTML::script('js/jquery.js') !!}
<!-- This should work -->
{!! Html::script('js/jquery.js') !!}
Or you could change the facade key to HTML
and then you can use HTML::script(...)
.
'HTML' => 'Illuminate\Html\HtmlFacade'
Upvotes: 1
Reputation: 907
you are using two different aliases to the same facade. the correct facades are
'Form' => Illuminate\Support\Facades\Facade\FormFacade::class,
'Html' => Illuminate\Support\Facades\Facade\HtmlFacade::class,
this should work
p.s. as of laravel 5.1 you should use facadeName::class
Upvotes: 0
Reputation: 7504
Try this:
{!! HTML !!}
and, don't forgot to composer dumpautoload
.
See, if that helps.
Upvotes: 0
Reputation: 8382
In migrating to 5.1 I found the same issue - it appears as though the HTML class no longer supports the script and style methods.
Instead, use:
{{ URL::asset('yourassetpath') }}
Upvotes: 0