How do I set up Bootstrap after downloading via Composer?
We have artisan command to publish the assets(CSS, JS,..). Something like this should work.
php artisan asset:publish --path="vendor/twitter/bootstrap/bootstrap/css" bootstrap/css
php artisan asset:publish --path="vendor/twitter/bootstrap/bootstrap/js" bootstrap/js
i am not sure about the path.. But this should work.
Just realised that php artisan asset:publish --path="vendor/twbs/bootstrap/dist/" bootstrap
or php artisan vendor:publish --path="vendor/twbs/bootstrap/dist/" bootstrap
do not work anymore.
What worked for me is editing the composer.json to add the following under scripts
, post-update-cmd
:
"scripts": {
"post-update-cmd": [
"php artisan optimize",
"mkdir -p public/bootstrap",
"cp -R vendor/twbs/bootstrap/dist/ public/bootstrap/"
]}
As the tutorial says, you have to copy it to your public directory:
cp vendor/twitter/bootstrap/docs/assets/js/html5shiv.js public/js/html5shiv.js
cp vendor/twitter/bootstrap/docs/assets/js/bootstrap.min.js public/js/bootstrap.min.js
EDIT:
You really have copy them, because your assets files should lie in the public folder only and Composer is all about putting packages on your vendor's folder, which must not be visible to the outside world.
But you can create a Composer post-install-cmd:
{
"scripts": {
"post-update-cmd": "MyVendor\\MyClass::postUpdate",
}
}
And make it copy those files for you every time an update happens. It can be written using PHP, bash or any other language you can run on your host. Docs: http://getcomposer.org/doc/articles/scripts.md.