Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Laravel 4 Basics Laravel Controllers Dynamic styles with Blade

Daniel Narvaez
Daniel Narvaez
16,319 Points

I can't find the method script in Laravel's API, and doesn't works the HTML class in Laravel 5.1.

It seems that the API has changed from version 4.2 (video) until now (5.1). Anybody knows the how to use the HTML class in the new API?

Idelle Diaz
Idelle Diaz
8,591 Points

In the composer.json file :

"require": { "laravelcollective/html": "~5.0" }

then in the terminal: vagrant@homestead:~/Sites/laravel-basics $ composer update

Next in the config/app.php file under aliases:

aliases' => [ // ... 'Form' => 'Illuminate\Html\Facades\Form::class', 'Html' => 'Illuminate\Html\Facades\Html::class', // ... ],

That should fix it for v5.0 - v5.4

3 Answers

Hello Daniel,

HTML and Form are no longer in the framework by default. To add them you need to add this to your composer.json

"require": { "laravelcollective/html": "5.1.*" }

In config/app.php register the service provide 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,

EDIT: Moved comment into the comment section so it now shows up next to the topic as an answer

I followed the steps above and got this error. I checked out ProviderRepository.php at line 146, but I can't figure out how to fix it...

FatalErrorException in ProviderRepository.php line 146: Class 'Collective\Html\HtmlServiceProvider' not found

Laurie Williams
Laurie Williams
10,174 Points

I figured it out. I'm running laravel 5.2.14

The class is not HTML in Laravel Collective. It's Html. eg: {!!Html::script('js/vendor/jquery.js') !!}

And the syntax is different now. Instead of {{{ it now uses {!!

Hope that helps anyone else who is struggling with this course.

Laurie Williams
Laurie Williams
10,174 Points

I'm having the same problem. Did you figure it out, Nathaniel?