bruyerefreelance/bb-seo-ezplatform-bundle
Installation
composer require bruyerefreelance/bb-seo-ezplatform-bundle
Add the bundle to app/AppKernel.php under registerBundles():
new BruyereFreelance\SeoExtensionBundle\BruyereFreelanceSeoExtensionBundle(),
Basic Configuration
Define content types (e.g., article, page_simple) in app/config/config.yml:
bruyere_freelance_seo_extension:
content_type_identifier: ['article', 'page_simple']
First Use Case
article).Content Creation/Editing
meta_title and meta_description.ContentController to inject SEO fields into the edit form:
// src/Acme/YourBundle/Controller/ContentController.php
public function editAction(Content $content)
{
$form = $this->createFormBuilder($content)
->add('meta_title', TextType::class, ['required' => false])
->add('meta_description', TextareaType::class, ['required' => false])
->getForm();
// ...
}
SEO Data Persistence
# config/ezplatform/content_types/article.yml
fields:
meta_title:
type: ezstring
position: 100
meta_description:
type: eztext
position: 101
Rendering SEO Tags
Twig template for content rendering to inject <title> and <meta> tags.Resources/views/Content/content.html.twig):
{% block meta_tags %}
{% if content.getField('meta_title') is not empty %}
<title>{{ content.getField('meta_title').value }}</title>
{% endif %}
{% if content.getField('meta_description') is not empty %}
<meta name="description" content="{{ content.getField('meta_description').value }}">
{% endif %}
{% endblock %}
API/Headless Use
// src/Acme/YourBundle/EventListener/ApiEventListener.php
public function onContentGet(ContentGetEvent $event)
{
$content = $event->getContent();
$seoData = [
'meta_title' => $content->getField('meta_title')?->value,
'meta_description' => $content->getField('meta_description')?->value,
];
$event->setData(array_merge($event->getData(), ['seo' => $seoData]));
}
Bundle Maturity
Field Configuration
meta_title and meta_description to your content types.content_type_identifier (e.g., article).Caching Issues
php bin/console cache:clear
Missing Documentation
BruyereFreelance\SeoExtensionBundle\DependencyInjection\ for configuration logic.Resources/config/services.yml for service definitions.Check Configuration
content_type_identifier includes all target content types:
bruyere_freelance_seo_extension:
content_type_identifier: ['article', 'page_simple', 'product'] # Add all needed types
Verify Field Existence
php bin/console ezplatform:content:list --type=article
meta_title/meta_description in the output.Override Default Behavior
{% extends 'ezdesign:layout.html.twig' %}
{% block head %}
{{ parent() }}
{% include 'AcmeYourBundle:Content/seo_tags.html.twig' with { content: content } %}
{% endblock %}
Extension Points
// src/Acme/YourBundle/EventSubscriber/SeoSubscriber.php
class SeoSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
KernelEvents::VIEW => ['onKernelView', 100],
];
}
public function onKernelView(ViewEvent $event)
{
$content = $event->getControllerResult();
if ($content instanceof Content) {
$event->getController()->get('twig')->addGlobal('seo_data', [
'title' => $content->getField('meta_title')?->value,
'description' => $content->getField('meta_description')?->value,
]);
}
}
}
Fallback for Missing Data
<title>
{% if content.getField('meta_title') is empty %}
{{ content.getName() }} - {{ site.name }}
{% else %}
{{ content.getField('meta_title').value }}
{% endif %}
</title>
How can I help you explore Laravel packages today?