Installation
Add the bundle to your composer.json:
composer require customscripts/core-bundle
Enable it in config/bundles.php:
return [
// ...
CustomScripts\CoreBundle\CSCoreBundle::class => ['all' => true],
];
First Use Case
Use the built-in layouts in Twig templates. Override the base template in templates/base.html.twig:
{% extends 'CSCoreBundle::layout.html.twig' %}
Choose a layout variant (e.g., one_column_left) by setting:
{% block layout %}
{{ parent() }} {# Inherits the selected layout #}
{% endblock %}
Asset Integration
Assets (Bootstrap, jQuery, etc.) are auto-registered via Twig’s assets function. Verify in app/config/config.yml:
twig:
paths:
'%kernel.project_dir%/vendor/customscripts/core-bundle/Resources/views': CSCoreBundle
Extending Layouts
Override layout.html.twig in your theme to modify structure:
{% extends 'CSCoreBundle::layout.html.twig' %}
{% block sidebar %}
{{ include('YourBundle::custom_sidebar.html.twig') }}
{% endblock %}
Dynamic Layout Selection Use Twig logic to switch layouts per route:
{% set layout = app.request.attributes.get('_route') == 'admin' ? 'one_column_right' : '3_columns' %}
{% block layout %}
{{ render(controller('CSCoreBundle:Layout:layout', {'layout': layout})) }}
{% endblock %}
Custom JavaScript/CSS
Add assets to web/js/ or web/css/ and reference them in Twig:
{{ assets('bundles/yourbundle/js/custom.js') }}
Ensure assets are compiled via Symfony’s asset pipeline (e.g., Webpack Encore).
Overriding Default Assets
Replace vendor assets by copying files to web/ (e.g., web/css/bootstrap.css). Symfony’s asset system will prioritize local files.
Admin vs. Frontend Theming Use environment-based Twig includes:
{% if app.environment == 'prod' %}
{{ assets('bundles/yourbundle/css/prod.css') }}
{% else %}
{{ assets('bundles/yourbundle/css/dev.css') }}
{% endif %}
Modular Components
Break templates into reusable components (e.g., components/navbar.html.twig) and include them:
{{ include('YourBundle::components/navbar.html.twig') }}
Asset Versioning
bootstrap.min.css?v=3.3.5). Override by configuring assets_version in config.yml:
cscore:
assets_version: '1.0.0' # Custom version string
php bin/console cache:clear) if assets fail to load after overrides.Layout Inheritance Conflicts
layout.html.twig breaks, check for missing {% block %} definitions. Use {{ dump(app.request.attributes) }} to debug route attributes.Font Awesome Icons
font-awesome.css to be loaded. Verify in layout.html.twig:
{{ assets('bundles/cscore/vendor/font-awesome/css/font-awesome.min.css') }}
Twig Template Paths List all loaded templates:
php bin/console debug:twig
Filter for CSCoreBundle to verify inheritance.
Asset Compilation
webpack.config.js includes:
Encore.enableSassLoader();
Encore.addEntry('app', './assets/app.scss');
npm run dev
Custom Layouts
Add new layouts by creating Resources/views/Layout/ in your bundle and reference them via:
{{ render(controller('CSCoreBundle:Layout:layout', {'layout': 'custom_layout'})) }}
Asset Overrides
Extend the bundle’s Resources/public/ directory by creating a YourBundle/Resources/public/ folder. Symfony’s asset system merges paths alphabetically.
Configuration
Override default settings in config/packages/cscore.yaml:
cscore:
default_layout: 'full_width' # Override default
enabled_assets:
- 'jquery'
- 'modernizr' # Disable by removing
How can I help you explore Laravel packages today?