How to include External CSS and JS file in Laravel 5

后端 未结 14 1617
庸人自扰
庸人自扰 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

    i use this way, don't forget to put your css file on public folder.

    for example i put my bootstrap css on

    "root/public/bootstrap/css/bootstrap.min.css"
    

    to access from header:

    <link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet" type="text/css" >
    

    hope this help

    0 讨论(0)
  • 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')
    "<input name=\"foo\" type=\"text\">"
    

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

    {!! HTML::style('foo/bar.css') !!}
    
    0 讨论(0)
提交回复
热议问题