How to install and use Bootstrap via Composer

0

Hello, how can I use Bootstrap in a Composer-managed project, I know that if you perform the composer require twbs / bootstrap command, the composer will download and place or the files in the vendor folder of the project, how do I add the code to the pages.

<link href="./vendor/twbs/bootstrap/dist/bootstrap.css">

Obeying the following project structure:

projeto/
---logs/
---public/
---src/
---template/
---tests/
---vendor/
---composer.json
---composer.lock

Would that be the right thing to do?

I believe this is not advisable, is there anything I can do to add it directly? Ex: <link href="./public/assets/bootstrap.css">

    
asked by anonymous 20.02.2018 / 00:42

1 answer

0

It's not the best way, but it's only to import into the project by composer.json:

{
   "name": "projeto/projeto",
   "description": "descricao.",
   "authors": [
      {
         "name": "nome",
         "email": "[email protected]"
      }
   ],
   "require": {
      "components/jquery": "^3.2",
      "twbs/bootstrap": "4.0.0"
   }
}

Or by the terminal:

  

composer require components / jquery

     

composer require twbs / bootstrap

And then include the files that are in /vendor :

<link href="vendor/twbs/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="vendor/components/jquery/jquery.min.js"></script>
<script src="vendor/twbs/bootstrap/dist/js/bootstrap.min.js"></script>

Note:

Bootstrap 4 will ask you to include Tether.io helper , just include your CDN path BEFORE of the bootstrap JavaScript file, getting these files needed.

<link href="vendor/twbs/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="vendor/components/jquery/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.3/js/tether.min.js"></script><scriptsrc="vendor/twbs/bootstrap/dist/js/bootstrap.min.js"></script>

Note 2:

If the index file is in public, where the path to the file is going to go, return to a folder before entering the full path:

  

../ vendor / path / to / o / file.format

    
20.02.2018 / 01:40