Download the PHP package lch/seo-bundle without Composer
On this page you can find all versions of the php package lch/seo-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lch/seo-bundle
More information about lch/seo-bundle
Files in lch/seo-bundle
Package seo-bundle
Short Description Provides minimal SEO items on front-page-having entities : slug, title, description
License MIT
Homepage https://github.com/compagnie-hyperactive/SeoBundle
Informations about the package seo-bundle
SEOBundle
This bundle add SEO capabilities for entities in any SF3 project. So far it handles:
- SEO meta (title, desc, slug with URL rewrite)
- Minimal OpenGraph implementation
- Canonical URL
Installation using composer
$ composer require lch/seo-bundle
Configuration and usage
- Configuration
- Entities preparations
- Form type usage
- Front rendering
Configuration
SeoBundle allows to generate minimal SEO requirements for specific pages (like homepage) or 'entity' pages (like news page). SEO for 'entity' pages is automatically generated. For specifics pages, follow these steps:
Entities preparation
To automatically generate SEO for 'entity' pages, follow theses 2 steps:
Seoable trait
Add Seoable
to any entity you want to have SEO settings on. This include
- seoTitle
- seoDescription
- slug field
SeoInterface implementation
Implements SeoInterface
and fill 5 methods
-
getSluggableFields
for getting fields name needed to build slug -
getRouteFields
for getting fields name needed to build routeAn array is expected here, each key based on following pattern : routeParameter => entityParameter
-
getRouteName
for allowing URL generation in SEO area (canonical URL, OpenGraph...) -
getSeoTitleDefaultValue
for pointing a field to use in case of SEO title empty (to generate default one) -
getOpenGraphData
should return an array with OpenGraph data, such as : So far,SeoInterface
declares following OG constants :Array returned example :
We assume that a unique constraint/index is set on slug field, or slug fields collection if more than one.
In addition, ton ensure proper form validation, be sure to add @UniqueEntity
constraint, at least on slug
field :
Form type usage
SeoType
The bundle provides an SeoType, you can add to entities implementing SeoInterface types
Note: attr
used are detailled with AdminBundle
Then, in the form twigs, add SEO form theme : {{ form_row(form.seo) }}
to ensure fields rendering and logic.
Front rendering
Simply add a seo block in your base.html.twig
in <head>
section
Then, override this block on each page you want to display SEO information, with a custom Twig function:
- Specific pages :
Note: app.request
needs to be setting up here to generate SEO according to current route defined in config.yml
- Entity pages :
Persistence
So far, add call to $this->get('lch.seo.tools')->seoFilling()
on controller before persist to ensure data will be set. Will be replaced with doctrine event later
All versions of seo-bundle with dependencies
symfony/framework-bundle Version ^4.2
symfony/twig-bundle Version ^4.2
twig/extensions Version 1.5.*
symfony/form Version ^4.2
symfony/orm-pack Version ^1.0
symfony/validator Version ^4.2
knplabs/doctrine-behaviors Version ^2.0
doctrine/annotations Version ^1.8
lch/components-bundle Version ^1.2