Installation Add the package via Composer:
composer require 7rin0/bigfoot-default-theme
Enable the bundle in config/bundles.php:
return [
// ...
SevenRin0\BigfootDefaultTheme\BigfootDefaultThemeBundle::class => ['all' => true],
];
First Use Case
Override the default theme by configuring config/packages/bigfoot_default_theme.yaml:
bigfoot_default_theme:
theme: 'default' # or your custom theme name
Clear cache to apply changes:
php bin/console cache:clear
Where to Look First
Resources/doc/ for theme structure and Twig templates.templates/ in the bundle to understand how to extend or replace templates.Resources/public/ for CSS/JS to customize styling.Create a Custom Theme
Copy the default theme to your project (e.g., templates/bigfoot/):
mkdir -p templates/bigfoot
cp -r vendor/7rin0/bigfoot-default-theme/Resources/views/* templates/bigfoot/
Override specific templates (e.g., base.html.twig) in your project’s templates/bigfoot/ directory.
Twig Integration
Use Twig’s {% extends %} and {% block %} to modify templates:
{% extends 'bigfoot/base.html.twig' %}
{% block title %}Custom Title{% endblock %}
Asset Management
Override CSS/JS by copying files from vendor/7rin0/bigfoot-default-theme/Resources/public/ to public/build/bigfoot/.
Enqueue assets in Twig:
{{ asset('build/bigfoot/custom.css') }}
Configuration
Extend the theme config in config/packages/bigfoot_default_theme.yaml:
bigfoot_default_theme:
theme: 'custom' # Your theme name
assets_path: '%kernel.project_dir%/public/build/bigfoot'
Dynamic Theme Switching Use a service or controller to switch themes at runtime:
// In a controller
$this->get('bigfoot_default_theme.theme_switcher')->setTheme('custom');
Cache Dependencies
php bin/console cache:clear --env=prod --no-debug
debug:config to verify theme settings:
php bin/console debug:config bigfoot_default_theme
Asset Paths
asset() function or Symfony’s %kernel.project_dir% parameter:
<link rel="stylesheet" href="{{ asset('build/bigfoot/style.css') }}">
Template Inheritance
base.html.twig) and use blocks properly.Bundle Maturity
SevenRin0/BigfootDefaultThemeBundle) for undocumented features or edge cases.Check Active Theme Dump the active theme in a Twig template:
{{ dump(app.get('bigfoot_default_theme.theme_switcher').getTheme()) }}
Template Debugging
Enable Twig’s debug mode in config/packages/twig.yaml:
twig:
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
Asset Debugging Verify asset paths with:
php bin/console assets:debug
Custom Theme Logic
Extend the ThemeSwitcher service by overriding the bundle’s configuration or creating a decorator:
# config/services.yaml
services:
App\Service\CustomThemeSwitcher:
decorates: 'bigfoot_default_theme.theme_switcher'
arguments: ['@.inner']
Event Listeners Hook into theme events (if the bundle provides them) to add custom logic:
// src/EventListener/ThemeListener.php
public function onThemeSwitch(ThemeEvent $event) {
// Custom logic
}
Twig Extensions Add custom Twig functions/filters for theme-specific logic:
// src/Twig/AppExtension.php
class AppExtension extends \Twig\Extension\AbstractExtension {
public function getFunctions() {
return [
new \Twig\TwigFunction('custom_theme_function', [$this, 'customFunction']),
];
}
}
How can I help you explore Laravel packages today?