Blog

Install bootstrap library into vendor directory

composer require twbs/bootstrap

Create Service Provider in 'app/Providers/AssetServiceProvider.php'

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AssetServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot()
    {
        $this->publishes([
            base_path('vendor/twbs/bootstrap/dist/css/bootstrap.min.css') => public_path('vendor/bootstrap/css/bootstrap.min.css'),
            base_path('vendor/twbs/bootstrap/dist/css/bootstrap-theme.min.css') => public_path('vendor/bootstrap/css/bootstrap-theme.min.css'),
            base_path('vendor/twbs/bootstrap/dist/fonts') => public_path('vendor/bootstrap/fonts'),
            base_path('vendor/twbs/bootstrap/dist/js/bootstrap.min.js') => public_path('vendor/bootstrap/js/bootstrap.min.js'),
        ], 'bootstrap');
    }

    /**
     * Register any application services.
     */
    public function register()
    {
        //
    }
}

Register Service Provider in 'config/app.php':

'providers' => [
    ...
    App\Providers\AssetServiceProvider::class,
    ...
]

Publish Assets

php artisan vendor:publish --tag="bootstrap" --force

Output

Copied File [/vendor/twbs/bootstrap/dist/css/bootstrap.min.css] To [/public/vendor/bootstrap/css/bootstrap.min.css]
Copied File [/vendor/twbs/bootstrap/dist/css/bootstrap-theme.min.css] To [/public/vendor/bootstrap/css/bootstrap-theme.min.css]
Copied Directory [/vendor/twbs/bootstrap/dist/fonts] To [/public/vendor/bootstrap/fonts]
Copied File [/vendor/twbs/bootstrap/dist/js/bootstrap.min.js] To [/public/vendor/bootstrap/js/bootstrap.min.js]
Publishing complete for tag [bootstrap]!

Add style- script tags in template

{{ Html::style('vendor/bootstrap/css/bootstrap.min.css') }}
{{ Html::style('vendor/bootstrap/css/bootstrap-theme.min.css') }}
{{ Html::script('vendor/bootstrap/js/bootstrap.min.js') }}

Composer Update

Edit 'composer.json':

"scripts": {
    ...
    "post-update-cmd": [
        "php artisan optimize",
        "php artisan vendor:publish --tag=bootstrap --force"
    ]
}

Next time you run composer update your Bootstrap is updated as well!

Zoeken