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>


  • | 177 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?


  • | 3180 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:


  • | 177 points

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


  • | 177 points

    @Kurre Sorry but I have one more question. I tried calling a glyphicon and I get this error http://domain.com.dev/css//fonts/glyphicons-halflings-regular.woff2?448c34a56d699c29117adc64c43affeb

    Any idea why it is trying to grab css//fonts?


  • | 3180 points

    @nate Hmm, can't really say for sure, as I haven't used BS for a long time.

    But, reading http://getbootstrap.com/components/#glyphicons-how-to-use tells me that those fonts should be included in the Bootstrap CSS and loaded via @font-face. And that it tries to find & load those fonts from the ../fonts/ directory, relative to the compiled css file.

    So, if you compile your CSS to /css/dist/site.css, it'll try to find those fonts from the /css/fonts directory. Thus that path.
    And that extra slash shouldn't make any difference.


Log in to reply
 

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