Installation
composer require c33s-toolkit/bootstrap3-bundle
Add to config/bundles.php:
return [
// ...
C33s\Bootstrap3Bundle\C33sBootstrap3Bundle::class => ['all' => true],
];
Basic Usage
Include the bundle’s assets in your base template (templates/base.html.twig):
{% block stylesheets %}
{{ parent() }}
{{ c33s_bootstrap3_stylesheets() }}
{% endblock %}
{% block javascripts %}
{{ parent() }}
{{ c33s_bootstrap3_javascripts() }}
{% endblock %}
First Layout Component Use the provided Twig extensions for common Bootstrap 3 components:
<div class="container">
{{ c33s_bootstrap3_alert('success', 'Operation completed!') }}
{{ c33s_bootstrap3_navbar() }}
</div>
Responsive Layouts
Use the c33s_bootstrap3_grid() helper to define responsive rows/columns:
{{ c33s_bootstrap3_grid(12, [
{ 'cols': 4, 'content': 'Sidebar' },
{ 'cols': 8, 'content': 'Main Content' }
]) }}
Dynamic Components Pass variables to customize components:
{{ c33s_bootstrap3_modal('confirm', {
'title': 'Delete Item',
'body': 'Are you sure?',
'footer': c33s_bootstrap3_modal_footer([
{ 'label': 'Cancel', 'type': 'button' },
{ 'label': 'Delete', 'type': 'submit', 'class': 'btn-danger' }
])
}) }}
Integration with Symfony Forms Extend form themes to use Bootstrap 3 classes:
{% form_theme form 'C33sBootstrap3Bundle:Form:fields.html.twig' %}
Asset Management Override default assets by copying files from:
vendor/c33s-toolkit/bootstrap3-bundle/Resources/public/
to your project’s web/ directory.
%kernel.debug% mode).c33s_bootstrap3_*.templates/C33sBootstrap3Bundle/ to modify default markup.Asset Loading Order
{{ c33s_bootstrap3_javascripts() }} is placed after jQuery in javascripts block.Twig Cache
php bin/console cache:clear after modifying templates or extensions.CSS Conflicts
!important sparingly; target specific classes instead (e.g., .my-class.btn).Symfony 4+ Upgrade
symfony/webpack-encore for modern setups.APP_DEBUG=true) for detailed Twig errors.{{ dump(c33s_bootstrap3_asset('css/bootstrap.min.css')) }} to verify asset paths.Custom Components Extend the bundle by creating new Twig extensions in your project:
// src/Twig/Extension/CustomBootstrapExtension.php
class CustomBootstrapExtension extends \Twig_Extension
{
public function getFunctions()
{
return [
new \Twig_SimpleFunction('c33s_custom_component', [$this, 'renderCustomComponent']),
];
}
}
Override Templates Copy and modify:
vendor/c33s-toolkit/bootstrap3-bundle/Resources/views/
to templates/C33sBootstrap3Bundle/.
Configuration
Override default settings via config/packages/c33s_bootstrap3.yaml:
c33s_bootstrap3:
theme: 'flatly' # Override default theme
responsive: true
# config/packages/framework.yaml
assets:
version: '%kernel.environment%'
How can I help you explore Laravel packages today?