Best method to use Bootstrap in Laravel 4

前端 未结 3 1511
醉梦人生
醉梦人生 2021-02-06 08:55

I am using now Laravel 4,
What is the best method to use bootstrap for my site?
Is there some stuff I need to change and where do I put the css files?

Someone sa

3条回答
  •  无人共我
    2021-02-06 09:15

    Some things you must know about Laravel:

    It has directly nothing to do with your front end, including Twitter Bootstrap.

    Where you put your files is entirely up to you, but the public folder is (usually) where your public viewable files must go.

    CSS and JavaScript files are directly downloaded by browser, so those files should be in your public folder.

    To download/use Bootstrap you have some options:

    1) Go to http://getbootstrap.com/ and download it.

    2) Use bower (https://github.com/bower/bower) to download it for you.

    3) If you are planning using a Bootstrap template, usually those already come with Bootstrap.

    4) Use a CDN, like http://www.bootstrapcdn.com/

    I, personally, use bower, those are the steps you can follow to install and use it:

    Install it

    [sudo] npm install bower
    

    Create a .bowerrc file in your project dir, which tells bower where to download your packages:

    {
        "directory": "public/bower"
    }
    

    Create a bower.json file, which holds your installed packages:

    {
      "name": "YourApp.com",
      "dependencies": {
      }
    }
    

    Then you just need to install your packages using it:

    bower install bootstrap -S
    bower install jquery -S
    

    And you can also use it to find packages

    bower search google-code-prettify
    

    After installing bootstrap, your css files would be located at:

    public/bower/bootstrap/dist/css/
    

    In Laravel there are many ways of including your assets, this is one of those, using Blade as you view compiler:

    
    

提交回复
热议问题