Laravel 5.1: Class html does not exist

前端 未结 9 2022
一个人的身影
一个人的身影 2020-12-10 04:38

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 \"laravelcollec
相关标签:
9条回答
  • 2020-12-10 05:08

    Please change your blade file from this

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

    to

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

    It's working.

    0 讨论(0)
  • 2020-12-10 05:09

    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.

    0 讨论(0)
  • 2020-12-10 05:12

    Try it

    php artisan cache:clear

    php artisan clear-compiled

    0 讨论(0)
  • 2020-12-10 05:17

    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') !!}
    
    0 讨论(0)
  • 2020-12-10 05:17

    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 讨论(0)
  • 2020-12-10 05:18

    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 讨论(0)
提交回复
热议问题