Installation
Run composer require c975l/site-bundle in your Laravel project (note: this is a Symfony bundle, but can be adapted via Laravel's Symfony integration or a bridge like spatie/laravel-symfony-support).
Enable Routes
Add to routes/web.php:
Route::group(['namespace' => 'C975L\SiteBundle\Controller'], function () {
require __DIR__.'/vendor/c975l/site-bundle/src/Resources/config/routes.php';
});
Publish Config
Run php artisan vendor:publish --provider="C975L\SiteBundle\SiteBundle" to publish default config (adjust for Laravel’s config/ structure).
First Use Case
Override the base layout in resources/views/layouts/app.blade.php (Symfony Twig) or resources/views/layouts/base.blade.php (Laravel) to extend the bundle’s default layout.
Layout Customization
site.html.twig in Symfony) by copying vendor/c975l/site-bundle/src/Resources/views/layouts/site.html.twig to resources/views/layouts/site.html.twig.{{ config('app.name') }}) alongside bundle variables (e.g., {{ site.title }}).Dynamic Site Data
Use the site/config route (protected by role) to manage:
site.matomo.url and site.matomo.id in config).site.cookie_consent.enabled).Exception Templates
Override Symfony’s exception templates by copying files from vendor/c975l/site-bundle/src/Resources/views/TwigBundle/Exception/ to resources/views/TwigBundle/Exception/.
Legal Pages Predefined templates for:
terms.html.twig).privacy.html.twig).
Render via routes like /terms (configured in routes.php).spatie/laravel-symfony-support to handle Symfony bundles in Laravel. Example:
// config/app.php
'providers' => [
Spatie\SymfonySupport\SymfonyServiceProvider::class,
C975L\SiteBundle\SiteBundle::class,
],
assets:install fails:
ln -s vendor/c975l/site-bundle/src/Resources/public/css /public/css/site
twig-to-blade or manually replace {{ }} with @{{ }} and |raw filters with {{ !! }}.Config Management:
c975l/config-bundle for runtime config. If missing, publish config manually:
php artisan vendor:publish --provider="C975L\ConfigBundle\ConfigBundle"
config/cache may conflict; disable caching during development:
// config/caching.php
'enabled' => env('APP_DEBUG') ? false : true,
Route Conflicts:
site/config route may clash with Laravel’s admin routes. Rename or prefix:
// routes/web.php
Route::prefix('admin')->group(function () {
// ...
});
Asset Loading:
ls -la public/css/site
public/ in post-install script:
cp -r vendor/c975l/site-bundle/src/Resources/public/css public/
Twig in Laravel:
config/twig.php:
'autoescape' => false,
config/site.php exists and is readable. Clear config cache:
php artisan config:clear
C975L\SiteBundle\SiteBundle is registered in config/app.php and routes are loaded after Laravel’s default routes.{# resources/views/layouts/site.html.twig #}
<title>{{ site.title }} | {{ config('app.name') }}</title>
app.url to Matomo config:
// config/site.php
'matomo' => [
'url' => env('MATOMO_URL', 'https://matomo.example.com'),
'id' => env('MATOMO_ID', '1'),
'base_url' => url('/'), // Laravel dynamic URL
],
cookie helper:
// app/Providers/AppServiceProvider.php
public function boot()
{
if (config('site.cookie_consent.enabled')) {
Cookie::queue('cc_accepted', 'true', 365);
}
}
How can I help you explore Laravel packages today?