alexandermatveev/bootstrap-bundle
Since this bundle is designed for Symfony2+, Laravel developers must manually adapt it. Start by:
Install via Composer (in Laravel project root):
composer require alexandermatveev/bootstrap-bundle
Publish Assets (Laravel’s public folder):
php artisan vendor:publish --tag=public --force
(Note: The bundle lacks Laravel-specific commands; use assets:install as a fallback.)
Register Assets in app.blade.php:
<!-- CSS -->
<link href="{{ asset('vendor/alexandermatveev/bootstrap-bundle/css/bootstrap.min.css') }}" rel="stylesheet">
<!-- JS (place before closing </body>) -->
<script src="{{ asset('vendor/alexandermatveev/bootstrap-bundle/js/bootstrap.min.js') }}"></script>
Verify Bootstrap Components Work: Test a basic modal or dropdown in a Blade template:
<button class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">Launch Modal</button>
<div class="modal fade" id="exampleModal">...</div>
// webpack.mix.js
mix.copy('node_modules/bootstrap/dist/css/bootstrap.min.css', 'public/css');
mix.copy('node_modules/bootstrap/dist/js/bootstrap.min.js', 'public/js');
mix() helper for hashed filenames:
<link href="{{ mix('css/bootstrap.min.css') }}" rel="stylesheet">
<!-- Twig (from bundle docs) -->
{% block stylesheets %}
{{ parent() }}
{{ asset('bundles/alexandermatveevbootstrap/js/bootstrap/css/bootstrap.min.css') }}
{% endblock %}
<!-- Blade -->
@vite(['resources/css/bootstrap.min.css'])
@include:
@include('partials.bootstrap.modal', ['title' => 'Custom Modal'])
<script src="{{ mix('js/jquery.min.js') }}"></script>
<script src="{{ mix('js/bootstrap.min.js') }}"></script>
@stack for deferred scripts:
@stack('scripts')
// In a Blade file
@push('scripts')
<script src="{{ mix('js/bootstrap.min.js') }}"></script>
@endpush
config/bootstrap.php:
return [
'version' => '5.3.0', // Custom Bootstrap version
'assets' => [
'css' => 'css/bootstrap.custom.min.css',
'js' => 'js/bootstrap.custom.min.js',
],
];
(Note: The bundle lacks a config system; manually manage paths.)Symfony-Specific Assumptions:
Asset component. In Laravel, use asset() or mix() instead.Resources/public directory in composer.json:
"extra": {
"laravel": {
"assets": ["public"]
}
}
Outdated Bootstrap Version:
yarn add bootstrap@5.No Laravel Service Provider:
BootstrapServiceProvider).// app/Providers/BootstrapServiceProvider.php
public function boot()
{
Blade::directive('bootstrapModal', function ($title) {
return "<?php echo \$this->bootstrapModal($title); ?>";
});
}
Asset Path Confusion:
bundles/alexandermatveevbootstrap path won’t exist in Laravel.vendor/alexandermatveev/bootstrap-bundle or symlink:
ln -s vendor/alexandermatveev/bootstrap-bundle/public web/bootstrap
Asset Loading Issues:
php artisan route:list or php artisan view:clear./vendor/... routes.JavaScript Errors:
console.log($); // Should return jQuery function
Component Styling:
/* Override Bootstrap's $primary color */
.btn-primary {
background-color: #6f42c1 !important;
}
Custom Builds:
mix.sass('resources/sass/bootstrap-custom.scss', 'public/css');
Plugin Integration:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
Server-Side Rendering (SSR):
// Inertia page component
import { usePage } from '@inertiajs/inertia-react';
const { props } = usePage();
if (props.requiresBootstrap) {
import('bootstrap');
}
Testing:
// tests/TestCase.php
public function setUp(): void
{
parent::setUp();
$this->withoutBootstrap(); // Hypothetical helper
}
How can I help you explore Laravel packages today?