Bootstrap with laravel 5.1 using Laragon


  • | 411 points

    1. i recently installed laragon.
    2. I am putting bootstrap's "css" and "js" folders in public directory.
    3. then i make an entry in "welcome.blade.php" in <head></head> as below

    <!DOCTYPE html>
    <html>
    <head>
    ** {!! HTML::script('public/js/jquery-1.12.1.min.js') !!}
    {!! HTML::script('public/js/bootstrap.min.js') !!}
    {!! HTML::style('public/css/bootstrap.min.css') !!}**
    </head>
    <body>
    <div class="container">
    <div class="content">
    <div class="title">Laravel 5</div>
    </div>
    </div>
    </body>
    </html>

    But I am unable to see changes on my site. please help.


  • | 411 points

    well I solved it myself.

    by-default the project path registered is till "public/" folder.
    So i kept my files directly in public folder and then used below page as

    <!DOCTYPE html>
    <html>
    <head>
    ** {!! HTML::script('/jquery-1.12.1.min.js') !!}
    {!! HTML::script('/bootstrap.min.js') !!}
    {!! HTML::style('/bootstrap.min.css') !!}

    </head>
    <body>
    <div class="container">
    <div class="content">
    <div class="title">Laravel 5</div>
    </div>**

    and it worked. When I checked the apache access.log, it showed that the request found the file at specified location: below is the log;

    127.0.0.1 - - [17/Mar/2016:20:42:23 +0530] "GET / HTTP/1.1" 200 481
    127.0.0.1 - - [17/Mar/2016:20:42:29 +0530] "GET /bootstrap.min.js HTTP/1.1" 200 36868
    127.0.0.1 - - [17/Mar/2016:20:42:29 +0530] "GET /jquery-1.12.1.min.js HTTP/1.1" 200 97403
    127.0.0.1 - - [17/Mar/2016:20:42:29 +0530] "GET /bootstrap.min.css HTTP/1.1" 200 121260
    127.0.0.1 - - [17/Mar/2016:20:42:29 +0530] "GET /favicon.ico HTTP/1.1" 304 -

    </div>


  • | 118 points

    So I am running in to this issue now. I installed bootstrap via composer and it put the files in the vendor folder. I tried copying them to the public folder but no matter what I do I can't call on them. Did you have that problem at all?


  • | 2665 points

    @nate

    All path are relative to /public folder.
    So if you have, for example your bootstrap files in public/css/botstrap, you could refer to those files like this:

    <!-- Note that you'll need laravelcollective/html composer package to use this HTML Facade -->
    {!! HTML:style('css/bootstrap/bootstrap.min.css') !!}
    {!! HTML::script('js/bootstrap/bootstrap.min.js') !!}
    
    <!-- And you would get -->
    <link media="all" type="text/css" rel="stylesheet" href="http://domain.com/css/bootstrap/bootstrap.min.css">
    <script src="http://domain.com/js/bootstrap/bootstrap.min.js"></script>
    

    which would work.

    Personally, I prefer using asset() or elixir() helpers like this:

    <link href="{{ asset('css/public.css') }}" rel="stylesheet" />
    <script src="{{ asset('js/public.js') }}"></script>
    
    <!-- And you would get -->
    <link href="http://domain.com/css/public.css" rel="stylesheet">
    <script src="http://domain.com/js/public.js"></script>
    

    Either way should work just fine :slight_smile:


  • | 118 points

    @Kurre That is perfect! Thank you so much. I appreciate the help and quick response


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.