I’ve downloaded bootstrapp with composer
composer.json
{ "name": "afern/seocom_login", "require": { "twbs/bootstrap": "3.3.7" } }
and I’ve included the autoload file on index.php
<?php include "./vendor/autoload.php"; ?> <html> <head> </head> <body> <h2>Hello</h2> </body> </html>
Bootstrap its downloaded on vendor folder but it’s not working I guess I also have to add this line to the html code
<link rel="stylesheet" href=".vendortwbsbootstrapbootstrap.min.css">
Am I right? or there is any way to work bootstrap only with
include "./vendor/autoload.php"
Advertisement
Answer
Composer is for managing your PHP dependencies, which appears to be your backend technology of choice. However, a UI framework, such as Bootstrap, is a frontend dependency (CSS and JS). Your proposed way of referencing the CSS in your HTML is the way to go:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
Same for jQuery and the Bootstrap JS:
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
It’s probably easiest for you if you embed it from a CDN as in my examples. If you want to serve the files yourself you could use bower to manage your frontend dependencies (although I think that is discontinued).
Your composer auto load script, however, is not what you need for this.