PHPackages                             leogout/seo-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. leogout/seo-bundle

AbandonedArchivedSymfony-bundle[Utility &amp; Helpers](/categories/utility)

leogout/seo-bundle
==================

A Symfony bundle to generate SEO meta tags.

v1.3.0(3y ago)40117.8k↓10.5%18[1 issues](https://github.com/leogout/SeoBundle/issues)[2 PRs](https://github.com/leogout/SeoBundle/pulls)2MITPHPCI passing

Since May 21Pushed 8mo ago5 watchersCompare

[ Source](https://github.com/leogout/SeoBundle)[ Packagist](https://packagist.org/packages/leogout/seo-bundle)[ RSS](/packages/leogout-seo-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (5)Versions (12)Used By (2)

Unmaintained
============

[](#unmaintained)

This bundle is unmaintained. Feel free to keep using it, it is quite stable (because it's just an overengeneered meta tag generator). I'll stop maintaining it from now on. Thanks for using it until now !

LeogoutSeoBundle
================

[](#leogoutseobundle)

This bundle provides a simple and flexible API to manage *search engine optimization* (SEO) tags in your application. Its main goal is to make it simple for you to manage the most common **meta**, **open graph** and **twitter card** tags and to let you configure less common ones with ease.

[![Test Runner](https://github.com/leogout/SeoBundle/actions/workflows/ci.yml/badge.svg)](https://github.com/leogout/SeoBundle/actions)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8e11049de729e6b8a6d086bf46f4667b095c83d3651c35288d43fce9be703686/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c656f676f75742f53656f42756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/leogout/SeoBundle/?branch=master)

Installation
------------

[](#installation)

Install the bundle with the command:

`composer require leogout/seo-bundle`

Register the bundle in your AppKernel:

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Leogout\Bundle\SeoBundle\LeogoutSeoBundle(),
        );
    }
}
```

Configuration
-------------

[](#configuration)

These configuration values are the defaults used to render your tags. See the next section to learn how to override them dynamically.

There are four sections in the config:

- `general`: The *global* configuration. Its values are shared among the other as defaults.
- `basic`: A set of the most common SEO tags.
- `og`: A set of *open graph* tags based on .
- `twitter`: A set of *twitter card* tags based on

See "Configuration reference" to get the whole configuration.

**In your `config.yml`:**

```
leogout_seo:
    general:
        title: Default title
        description: Default description.
        image: http://images.com/poneys/12/large # This one is shared by open graph and twitter only
    basic:
        title: Awesome title
        keywords: default, keywords
    og:
        type: website
        url: http://test.com/articles
    twitter:
        card: summary
        site: '@leogoutt'
```

**In your view:**

```

    {{ leogout_seo() }}

```

**NOTE:** *You can provide a generator name to the `leogout_seo()` twig method to render it specifically. For example, to render the `basic` seo generator, you can use `leogout_seo('basic')`.*

**The result:**

```

    Awesome title

```

**NOTE:** *By default, the SEO generators aren't loaded if you don't require them in the config. However, if you want to use the associated generators without configuring any default values (or configuring only the general ones), you can use this notation:*

```
leogout_seo:
   general:
       title: Default title
       description: Default description.
       image: http://images.com/poneys/12/large # This one is shared by open graph and twitter only
   basic: ~
   og: ~
   twitter: ~
```

Setting values dynamically
--------------------------

[](#setting-values-dynamically)

You can get the `'[basic|twitter|og]` as a service to set or override any values. Each value of the configuration can be overrided using a setter of the following form: `$this->get('leogout_seo.provider.generator')->get('` **\[basic|twitter|og\]** `')->set` **\[config field name\]** `(` **\[value\]** `)`

For example, if you want to change `title` and `robots` from `basic`, you can do this:

```
class DefaultController extends Controller
{
    public function indexAction()
    {
        $this->get('leogout_seo.provider.generator')->get('basic')
            ->setTitle('Title set in controller')
            ->setRobots(true, false); // they can be chained

        return $this->render('AppBundle:Default:index.html.twig');
    }
}
```

Setting values from a resource
------------------------------

[](#setting-values-from-a-resource)

You can configure your own model classes to let the seo generators do all the work thanks to the **fromResource()** method. Multiple interfaces are available to help the method guess which setters to call to fill the tags.

This is an exemple for the `basic` generator: **In your resource:**

```
use Leogout\Bundle\SeoBundle\Seo\Basic\BasicSeoInterface;

class MyResource implements BasicSeoInterface
{
    protected $name;
    protected $description;
    protected $tags = [];

    // ...Your logic

    // These methods are from BasicSeoInterface and have to
    // return a string (or an object with a __toString() method).
    public function getSeoTitle()
    {
        return $this->name;
    }
    public function getSeoDescription()
    {
        return $this->description;
    }
    public function getSeoKeywords()
    {
        return implode(',', $this->tags);
    }
}
```

**In your controller:**

```
class MyController extends Controller
{
    public function indexAction(Request $request)
    {
        $myResource = new MyResource();
        $myResource
            ->setName('Cool resource')
            ->setDescription('Some description')
            ->addKeyword('hey')
            ->addKeyword('ho')
            ->addKeyword('let's go!');

        $this->get('leogout_seo.provider.generator')->get('basic')->fromResource($myResource);

        return $this->render('MyController:Default:index.html.twig');
    }
}
```

**In your view:**

```

    {{ leogout_seo('basic') }}

```

**The result:**

```

    Cool resource

```

There are **three** main interfaces, one for each generator:

- `BasicSeoInterface` for `basic`
- `OgSeoInterface` for `og`
- `TwitterSeoInterface` for `twitter`

These interfaces extends *simpler interfaces* which you can inplement instead or additionnally. For example, if you only have a meta description on your resource, you can implement `DescriptionSeoInterface` only to provide a description alone. This is the list of the different interfaces and what they extends:

TitleSeoInterfaceDescriptionSeoInterfaceKeywordsSeoInterfaceImageSeoInterfaceBasicSeoInterfaceXXXOgSeoInterfaceXXXTwitterSeoInterfaceXXXAdvanced usage
--------------

[](#advanced-usage)

If the built-in generators don't suit your needs, LeogoutSeoBundle provides a way to create your own SEO generators. First, you have to create a class that extends the AbstractSeoGenerator class:

```
use Leogout\Bundle\SeoBundle\Seo\AbstractSeoGenerator;

class MyTagsGenerator extends AbstractSeoGenerator
{
    public function setMyTag($content)
    {
        $this->tagBuilder->addMeta('myTag')
            ->setType(MetaTag::NAME_TYPE)
            ->setValue('myAwesomeTag')
            ->setContent((string) $content);

        return $this;
    }

    public function getMyTag()
    {
        return $this->tagBuilder->getMeta('myTag');
    }
}
```

Then, register it as a service and add it a `leogout_seo.generator` tag and a custom alias. Don't forget the `@leogout_seo.builder` dependency:

```
services:
    app.seo_generator.my_tags:
        class:     AppBundle\Generator\MyTagsGenerator
        arguments: [ '@leogout_seo.builder' ] # This is required
        tags: { name: leogout_seo.generator, alias: my_tags }
```

That's it, now you can use it alongside the others:

**In your controller:**

```
class MyController extends Controller
{
    public function indexAction(Request $request)
    {
        $this->get('leogout_seo.provider.generator')->get('my_tags')->setMyTag('cool');

        return $this->render('MyController:Default:index.html.twig');
    }
}
```

**In your view:**

```

    {{ leogout_seo('my_tags') }}

```

**Result:**

```

```

Configuration reference
-----------------------

[](#configuration-reference)

```
leogout_seo:
    general:
        title: Default title
        description: Default description.
        image: http://images.com/poneys/12/large
    basic:
        title: Basic title
        description: Basic description.
        keywords: default, keywords
        canonical: http://test.com
        robots:
            index: false
            follow: false
    og:
        title: Open graph title
        description: Open graph description.
        image: http://images.com/poneys/12/large
        type: website # article, book, profile
        url: http://test.com/articles
    twitter:
        title: Twitter title
        description: Twitter description.
        image: http://images.com/poneys/12/thumbnail
        card: summary # summary_large_image
        site: '@leogoutt' # optionnal
```

Contributing
------------

[](#contributing)

If you want to contribute (thank you!) to this bundle, here are some guidelines:

- Please respect the [Symfony guidelines](http://symfony.com/doc/current/contributing/code/standards.html)
- Test everything! Please add tests cases to the tests/ directory when:
    - You fix a bug that wasn't covered before
    - You add a new feature
    - You see code that works but isn't covered by any tests (there is a special place in heaven for you)

Todo
----

[](#todo)

- Packagist

Thanks
------

[](#thanks)

Many thanks to the [ARCANEDEV/SEO-Helper](https://github.com/ARCANEDEV/SEO-Helper) who authorized me to take some ideas from their library and to [KnpMenuBundle](https://github.com/KnpLabs/KnpMenuBundle) which inspired me for the Providers APIs.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance43

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 79.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~222 days

Total

9

Last Release

1376d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9843962?v=4)[Léo Richard](/maintainers/leogout)[@leogout](https://github.com/leogout)

---

Top Contributors

[![leogout](https://avatars.githubusercontent.com/u/9843962?v=4)](https://github.com/leogout "leogout (58 commits)")[![tugrul](https://avatars.githubusercontent.com/u/163442?v=4)](https://github.com/tugrul "tugrul (13 commits)")[![innerspirit](https://avatars.githubusercontent.com/u/305197?v=4)](https://github.com/innerspirit "innerspirit (2 commits)")

---

Tags

seo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/leogout-seo-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/leogout-seo-bundle/health.svg)](https://phpackages.com/packages/leogout-seo-bundle)
```

###  Alternatives

[stfalcon/tinymce-bundle

This Bundle integrates TinyMCE WYSIWYG editor into a Symfony2 project.

2692.9M24](/packages/stfalcon-tinymce-bundle)[sonata-project/seo-bundle

Symfony SonataSeoBundle

1442.7M41](/packages/sonata-project-seo-bundle)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)[leapt/core-bundle

Symfony LeaptCoreBundle

2529.1k4](/packages/leapt-core-bundle)[kphoen/sitemap-bundle

Provides a way to create/generate a sitemap using Doctrine, etc.

2444.8k](/packages/kphoen-sitemap-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
