Installation:
composer require bigfoot/seo-bundle
Add the bundle to config/bundles.php under C2IS\BigFoot\SeoBundle\BigFootSeoBundle.
Database Migration:
Run migrations to create the required tables (check src/Resources/migrations/ for schema). If using Symfony’s Doctrine migrations, ensure they’re imported.
Backend Access:
Navigate to /admin/seo in your backend to access the SEO management UI. No additional configuration is needed for basic functionality.
Dynamic Meta Tags for a Route:
hotel_show) in your routes.yaml or controller.hotel_name) with the route.Hotel ::hotel_name:.::hotel_name: with the actual value (e.g., "Grand Hotel") when rendering the page.Route-Based SEO Management:
/blog/{slug}), create a parameter post_title and use it in the SEO title field.Parameter Binding:
product_name and product_price to the route product_show.Twig Integration:
<head> section. Extend the base template (base.html.twig) to include:
<title>{{ app.seo.title }}</title>
<meta name="description" content="{{ app.seo.description }}">
<meta name="keywords" content="{{ app.seo.keywords }}">
Fallback Logic:
config/packages/bigfoot_seo.yaml:
default:
title: "Default Title"
description: "Default description for pages without SEO rules."
API/Non-HTML Responses:
_seo: false
Parameter Validation:
NotBlank, Length) before rendering SEO tags.hotel_name is not empty in the hotel_show route.Multi-Language Support:
Event Listeners:
bigfoot.seo.pre_render event to modify metadata dynamically:
// src/EventListener/SeoListener.php
public function onPreRender(SeoEvent $event) {
if ($event->getRoute() === 'homepage') {
$event->setTitle('Welcome to ' . config('app.name'));
}
}
Register the listener in services.yaml:
services:
App\EventListener\SeoListener:
tags:
- { name: kernel.event_listener, event: bigfoot.seo.pre_render, method: onPreRender }
Outdated Dependencies:
Route Name Mismatches:
routes.yaml match those used in the admin panel.dump(app->get('router')->getRouteCollection()->getNameConverter()) to list all route names.Parameter Placeholder Syntax:
::parameter_name:) is case-sensitive and must match exactly what’s defined in the admin panel.Caching Issues:
php bin/console cache:clear
cache:pool:clear for specific pools (e.g., seo_cache).Missing Admin Route:
/admin/seo route may not appear if the bundle isn’t properly registered in bundles.php or if Symfony’s security firewall blocks it.seo route exists via php bin/console debug:router | grep seo.Log SEO Events: Add a subscriber to log SEO rendering:
public function onPostRender(SeoEvent $event) {
\Log::debug('SEO Rendered', [
'route' => $event->getRoute(),
'title' => $event->getTitle(),
'description' => $event->getDescription(),
]);
}
Inspect Database:
Check the seo_parameter and seo tables directly to verify entries:
SELECT * FROM seo_parameter WHERE route_name = 'hotel_show';
SELECT * FROM seo WHERE route_name = 'hotel_show';
Custom Parameter Sources: Override the parameter resolver to fetch values from non-admin sources (e.g., API calls):
// src/Resolver/CustomParameterResolver.php
public function resolve($parameterName, Route $route) {
if ($parameterName === 'api_data') {
return $this->fetchFromExternalApi();
}
return parent::resolve($parameterName, $route);
}
Register as a service with the tag bigfoot.seo.parameter_resolver.
Additional Meta Tags:
Extend the bundle’s SeoManager to support custom meta tags (e.g., OpenGraph):
// src/Service/ExtendedSeoManager.php
public function getOpenGraphTags() {
return $this->getParameter('og_title') ?: [];
}
Update Twig templates to render these new tags.
Bulk SEO Imports:
Use Doctrine’s EntityManager to bulk-insert SEO rules via a command:
// src/Command/ImportSeoCommand.php
$seoRepository->save(new Seo([
'routeName' => 'product_show',
'title' => 'Product ::product_name:',
'description' => 'Details for ::product_name:',
]), true);
Override Twig Variables: Extend the bundle’s Twig environment to add custom variables:
# config/packages/twig.yaml
twig:
globals:
app_seo_extended: '@bigfoot_seo.manager'
Access in Twig: {{ app_seo_extended.getCustomTag('canonical_url') }}.
### Configuration Quirks
- **Parameter Order**:
If multiple parameters share the same name across routes, the **last defined** in the database takes precedence.
- **Empty Parameters**:
The bundle doesn’t validate empty parameters by default. Add a validator to the `SeoParameter` entity to enforce non-empty values.
- **Route Collection Refresh**:
After adding new routes, refresh the route collection:
```bash
php bin/console debug:router
How can I help you explore Laravel packages today?