How to include External CSS and JS file in Laravel 5

后端 未结 14 1780
庸人自扰
庸人自扰 2020-11-30 19:18

I am Using Laravel 5.0 , the Form and Html Helper are removed from this version , i dont know how to include external css and js files in my header file. Currently i am usin

14条回答
  •  一整个雨季
    2020-11-30 19:48

    First you have to install the Illuminate Html helper class:

    composer require "illuminate/html":"5.0.*"
    

    Next you need to open /config/app.php and update as follows:

    'providers' => [
    
    ...
    
    Illuminate\Html\HtmlServiceProvider::class,
    ],
    
    'aliases' => [
    
    ...
    
    'Form' => Illuminate\Html\FormFacade::class, 
    'HTML' => Illuminate\Html\HtmlFacade::class,
    ],
    

    To confirm it’s working use the following command:

    php artisan tinker
    > Form::text('foo')
    ""
    

    To include external css in you files, use the following syntax:

    {!! HTML::style('foo/bar.css') !!}
    

提交回复
热议问题