Laravel 5 Class 'HTML' not found

前端 未结 14 1579
野性不改
野性不改 2020-12-10 01:03

I am attempting to use Laravel 5 but my {{ HTML::style(\'style.css\') }} No longer works.

I have updated composer.json to include \"illuminate/ht

相关标签:
14条回答
  • 2020-12-10 01:06

    Anybody who are using laravel 5.* have to use laravelcollective/html because Package illuminate/html is abandoned, you should avoid using it.

    your composer.json file should contain following code in require section(as i am using laravel 5.2 it will be mentioned as 5.2)

    "laravelcollective/html": "5.2.*"
    

    run composer update

    and your config/app.php should contain following code in providers array

    'providers' => [
                           Collective\Html\HtmlServiceProvider::class,
    
    ]
    

    and aliases should contain

    'aliases' => [
    
                    'Form' => Collective\Html\FormFacade::class,
                    'HTML' => Collective\Html\HtmlFacade::class,
    ]
    

    and please note that whatever aliase you mentioned should appear in your code as

    {{HTML::linkAction('MemberController@show', 'view', array($value->id))}}
    
    0 讨论(0)
  • 2020-12-10 01:06

    run this cmd to laravel installed folder

    composer require "laravelcollective/html":"^5.4.0"
    

    and use with public

    {!! Html::style( asset('public/css/artist.css')) !!}
    
    0 讨论(0)
  • 2020-12-10 01:06
    'providers' => [
         Collective\Html\HtmlServiceProvider::class,
        ]
    
        'aliases' => [
              'Form' => Collective\Html\FormFacade::class,
              'Html' => Collective\Html\HtmlFacade::class,
        ]
    
    0 讨论(0)
  • 2020-12-10 01:11

    I think it's a case sensitive problem.

    If you register it as 'HTML'=> 'Illuminate\Html\HtmlFacade' in app.php, you can't use it as html or Html ( then it will only work when you use HTML).

    0 讨论(0)
  • 2020-12-10 01:11

    Follow this documentation how to fix it:

    https://laravelcollective.com/docs/5.4/html

    For each version you change the version number to access the appropriate doc e.g

    https://laravelcollective.com/docs/5.x/html

    x is the version

    0 讨论(0)
  • 2020-12-10 01:21
    {!! Html::style( asset('public/css/artist.css')) !!}
    

    ... worked for me, but this

    {{ HTML::style( asset('css/artist.css')) }}
    

    ... did not worked. But it should work. No!

    Laravel is confusing me more from day to day. I try to learn this ... Notwell :D

    0 讨论(0)
提交回复
热议问题