Install the Bundle
composer require agence-adeliom/easy-seo-bundle
Ensure your composer.json includes the Flex endpoint for seamless integration.
Enable the Bundle
The bundle auto-registers with Symfony Flex, so no manual AppKernel.php changes are needed.
Add SEO to an Entity
Extend your entity with the EntitySeoTrait:
use Adeliom\EasySeoBundle\Traits\EntitySeoTrait;
class Article
{
use EntitySeoTrait;
}
Configure Basic SEO in EasyAdmin
Add the SEOField to your CRUD controller:
use Adeliom\EasySeoBundle\Field\SEOField;
class ArticleCrudController extends AbstractCrudController
{
public function configureFields(string $pageName): iterable
{
yield SEOField::new('seo');
}
}
Render SEO in Twig Use the provided Twig functions in your templates:
{{- seo_title(object.seo) -}}
{{- seo_metas(object.seo) -}}
{{- seo_breadcrumb() -}}
Entity Setup
Add EntitySeoTrait to your entity (e.g., Product, BlogPost).
class BlogPost
{
use EntitySeoTrait;
}
EasyAdmin Integration
Include the SEOField in your CRUD controller’s configureFields() method.
yield SEOField::new('seo')
->setLabel('SEO Settings')
->setColumns(3);
Customize SEO Output Override default behavior via events (e.g., modify titles dynamically):
$dispatcher->addListener('easyseo.title', function (Event $event) {
$title = $event->getArgument('title');
$event->setArgument('title', 'Custom Prefix: ' . $title);
});
Twig Integration Embed SEO tags in your base template:
{% block meta %}
{{- seo_metas(object.seo) -}}
{% endblock %}
Dynamic SEO for Collections
Use the easyseo.render_meta event to inject dynamic meta tags (e.g., OpenGraph for lists):
$dispatcher->addListener('easyseo.render_meta', function (Event $event) {
$seoData = $event->getArgument('datas');
$seoData['opengraph']['type'] = 'website';
$event->setArgument('datas', $seoData);
});
Breadcrumb Customization
Modify breadcrumb structure via the easyseo.breadcrumb event:
$dispatcher->addListener('easyseo.breadcrumb', function (Event $event) {
$items = $event->getArgument('items');
array_unshift($items, ['label' => 'Home', 'url' => path('home')]);
$event->setArgument('items', $items);
});
Conditional SEO
Disable SEO for specific routes in easy_seo.yaml:
easy_seo:
ignore_profiler:
- '^/admin*'
- '^/api/*'
Entity Trait Conflicts
EntitySeoTrait may conflict with existing traits (e.g., Timestampable).SeoInterface explicitly or merge trait methods manually.Caching Headaches
php bin/console cache:clear
Event Dispatcher Order
$dispatcher->addListener('easyseo.title', [$this, 'modifyTitle'], 100); // Higher priority
Twig Function Scope
seo_title() or seo_metas() may fail if object.seo is undefined.{% if object.seo is not null %}
{{- seo_title(object.seo) -}}
{% endif %}
Profiler Integration Enable the Symfony profiler to inspect SEO data:
easy_seo:
enable_profiler: '%kernel.debug%'
Access the EasySeo tab in the profiler for real-time metadata previews.
Log SEO Events Debug event listeners by logging arguments:
$dispatcher->addListener('easyseo.title', function (Event $event) {
\Log::debug('SEO Title Event', ['title' => $event->getArgument('title')]);
});
Validate SEO Fields Use EasyAdmin’s validation to enforce SEO requirements:
yield SEOField::new('seo')
->setValidationGroups(['Default', 'seo']);
Custom Meta Tags
Extend the SeoInterface to add proprietary meta fields:
interface SeoInterface extends \Adeliom\EasySeoBundle\Model\SeoInterface
{
public function getCustomMeta(): string;
}
Sitemap Integration
Leverage presta/sitemap-bundle (dependency) to auto-generate sitemaps from SEO entities:
presta_sitemap:
sitemaps:
default:
routes: ['app_homepage']
entities: [App\Entity\Article]
Multi-Language Support Use Symfony’s translation system to localize SEO fields:
$seo->setTitle($translator->trans('article.title', [], 'seo'));
How can I help you explore Laravel packages today?