firestorm23 / seobundle
SEO manager, sitemap generator
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Type:symfony-bundle
Requires
- php: >=5.3.0
- presta/sitemap-bundle: ~1.4.0
- sonata-project/seo-bundle: ~1.1
README
The SEOBundle provides a Symfony Bundle capable of handling auto generated meta tags, specific tags by route and sitemaps.
Installation
- Install the package
composer require 'alpixel/seobundle'
- Update AppKernel.php
new Alpixel\Bundle\SEOBundle\SEOBundle(),
- Update DB Schema
php app/console doctrine:schema:update --force --dump-sql
Meta tags annotation
There are 2 options for defining meta tags in your application :
Static tags
Work in progress
Dynamic tags with placholders
If you have meta tags which need to be defined from entities value, you can use the @MetaTag annotation in your controller.
use Alpixel\Bundle\SEOBundle\Annotation\MetaTag; ... /** * @Route("/paupiette") * @MetaTag("paupiette", providerClass="My\Project\Entity\Paupiette", title="Paupiette page") */ public function displayAction() {
After you set up the annotation, you'll need to run the following command which will register your new annotation in database.
php app/console alpixel:seo:metatag:dump
Then you will have a new entry in the back office on the "SEO" panel. You should be able to configure the meta tags pattern for the given controller.
The impacted entity should provide placeholders. First, it should implements the Alpixel\Bundle\SEOBundle\Entity\MetaTagPlaceholderInterface Then you have to implement the getPlaceholders() method in your entity. This is an example :
use Alpixel\Bundle\SEOBundle\Entity\MetaTagPlaceholderInterface; class News implements MetaTagPlaceholderInterface { public function getPlaceholders() { return array( "[news:title]" => $this->title, "[news:resume]" => substr(strip_tags($this->content), 0, 150) ); } }