Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
238 views
in Technique[技术] by (71.8m points)

php - Laravel 5.1: Class html does not exist

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 CollectiveHtmlHtmlServiceProvider::class to providers in app.php
  • add Form' => CollectiveHtmlFormFacade::class, Html' => CollectiveHtmlHtmlFacade::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 Illuminatehtml 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:Devwwwadmin
esourcesviewsclubsindex.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Add in composer.json

 "illuminate/html": "5.*"

and run composer update

Open your config/app.php

add under 'providers'

IlluminateHtmlHtmlServiceProvider::class,

add under 'aliases'

'Form'      => IlluminateHtmlFormFacade::class,
'Html'      => IlluminateHtmlHtmlFacade::class,

and under your blade templates, use as such

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...