PHPackages                             romi45/yii2-seo-behavior - 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. romi45/yii2-seo-behavior

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

romi45/yii2-seo-behavior
========================

Seo behavior for Yii2 models and meta tags helper with patterns using possibility

1.1.1(5y ago)82823[2 issues](https://github.com/agilov/yii2-seo-behavior/issues)MITPHP

Since Feb 19Pushed 5y ago2 watchersCompare

[ Source](https://github.com/agilov/yii2-seo-behavior)[ Packagist](https://packagist.org/packages/romi45/yii2-seo-behavior)[ RSS](/packages/romi45-yii2-seo-behavior/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (1)Versions (15)Used By (0)

Seo meta contents behavior for Yii 2
====================================

[](#seo-meta-contents-behavior-for-yii-2)

This extension provides behavior functions for seo meta tags and title tag support. Also provides view helper for registering meta tags and title.

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

[](#installation)

My favorite way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
$ composer require romi45/yii2-seo-behavior:~1.0
```

or add

```
"romi45/yii2-seo-behavior": "~1.0"

```

to the `require` section of your `composer.json` file.

and then run migration

```
php yii migrate --migrationPath="@vendor/romi45/yii2-seo-behavior/migrations"

```

Configuring
-----------

[](#configuring)

First you need to configure your model:

```
use romi45\seoContent\components\SeoBehavior;

class Post extends ActiveRecord
{

    /**
     * @inheritdoc
     */
    public function behaviors() {
        return [
            [
                'seo' => [
                    'class' => SeoBehavior::className(),

                    // This is default values. Usually you can not specify it
                    'titleAttribute' => 'seoTitle',
                    'keywordsAttribute' => 'seoKeywords',
                    'descriptionAttribute' => 'seoDescription'
                ],
            ],
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            // ...
            [['seoTitle', 'seoKeywords', 'seoDescription'], 'safe'],
            [['seoTitle'], 'checkSeoTitleIsGlobalUnique'], // It recommends for title to be unique for every page. You can ignore this recommendation - just delete this rule.
            // ...
        ];
    }
}
```

Now you are ready to use it on form

```
