11
votes

I am upgrading from 4.2 directly to 5.1 and run into problems with the Html and Form classes.

I followed the upgrade notes, and did

  • add "laravelcollective/html": "~5.0" to composer.json
  • composer update
  • add Collective\Html\HtmlServiceProvider::class to providers in app.php
  • add Form' => Collective\Html\FormFacade::class, Html' => Collective\Html\HtmlFacade::class to aliases in app.php

But my views don't work. I get either Class HTML does not exist when using HTML::router or get Class html does not exist when using link_to_route

I also tried Illuminate\html instead of laravelcollective, I did a composer dump-autoload.

The complete errors:

ErrorException in Container.php line 736: Class html does not exist (View: C:\Dev\www\admin\resources\views\clubs\index.blade.php)
ReflectionException in Container.php line 736: Class html does not exist

What am I missing?


I tried everyone's answers and none of them worked for me for some reason. Ultimately I created a completely new laravel application, copied my code and then it started working, So though solved the actual problem remains a mystery.

9
May I ask what one of your blade variables looks like? {{!! Html.... !!} or {{ Html.... }}?camelCase
I tried all kinds, {{ }} and {!! !}} and I tried Html, HTML and html, nothing works. I am thinking of completely re-installing laravel and working from scratch.Michiel van der Blonk
Update: I had to revert everything to laravel 5.0 because the PHP version of my new server couldn't run 5.1. Dang.Michiel van der Blonk

9 Answers

16
votes

Add in composer.json

 "illuminate/html": "5.*"

and run composer update

Open your config/app.php

add under 'providers'

Illuminate\Html\HtmlServiceProvider::class,

add under 'aliases'

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

and under your blade templates, use as such

{!! HTML::style('assets/css/flatten.css') !!}
10
votes

My solution in my case it was problem with CASE-Sensitive class name.

In my config/app.php (in aliases)
'Form'      => Collective\Html\FormFacade::class,
'Html'      => Collective\Html\HtmlFacade::class,

I am tried to use in view this code:

{!! HTML::mailto('mailto:[email protected]', '[email protected]'); !!}

and that was an error:

"FatalErrorException in ccf70b1d0b9930d6c4e8f3859fff448f line 11: Class 'HTML' not found"

Name of class 'HTML' is CASE-Sensitive. You should use 'Html' as in your config (config/app.php) file.

Hope this help for some people.

3
votes

Please change your blade file from this

{{ HTML::style('css/bootstrap.min.css') }}

to

{{ Html::style('css/bootstrap.min.css') }}

It's working.

2
votes

A simple restart after composer update worked perfectly for me. I was looking for the answer, and got stuck at the same position. I'd suggest, run config:cache and cache:clear and restart the IDE. It will work.

1
votes

My problem is solved, but the actual cause is still unknown. I have created a completely new laravel install and copied my source (all of it). The new application worked right away (after installing illuminate/html).

So you think I did something wrong with packages? That's what I thought, and then I did a diff on the two directories, only to find out they were identical. So it's a real mystery.

So, now everything is working, I simply renamed my new application and can continue.

I do know at some point I probably had both the collective and the illuminate versions of the HTML package installed. That's what most likely corrupted everything.

0
votes

this is right way If you try to use Form::open() or any of the Form methods in a fresh Laravel 5 install, you would get something like this: http://laraveldaily.com/class-form-not-found-in-laravel-5/

0
votes

I think I have found the solution.

In your app.php you have declared

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

While in your View you have called the same class as

{!! HTML::style('css/bootstrap.min.css') !!}

There is nothing wrong with the packages as the marked answer above but rather difference in capitalization of the word HTML as the previous documentation ver 5.0.*.

It should be

'Form'      => Illuminate\Html\FormFacade::class,
'HTML'      => Illuminate\Html\HtmlFacade::class,
0
votes

Try it

php artisan cache:clear

php artisan clear-compiled

0
votes

edit config/app.php

add this into providers

Collective\Html\HtmlServiceProvider::class,

and this into aliases

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