PHPackages                             nevmerzhitsky/yii2-seomodule - 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. nevmerzhitsky/yii2-seomodule

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

nevmerzhitsky/yii2-seomodule
============================

SEO-oriented functional for models and controllers

025PHP

Since Jan 20Pushed 10y ago2 watchersCompare

[ Source](https://github.com/nevmerzhitsky/yii2-seomodule)[ Packagist](https://packagist.org/packages/nevmerzhitsky/yii2-seomodule)[ RSS](/packages/nevmerzhitsky-yii2-seomodule/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

yii2-seomodule
==============

[](#yii2-seomodule)

Add ability to edit content of SEO-oriented HTML tags and attributes. Also add ability to configure redirection from any route to another with 301 status. And more SEO-oriented functions.

Highly inspired by  and .

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

[](#installation)

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

Either run

```
php composer.phar require nevmerzhitsky/yii2-seomodule "*"

```

or add

```
"nevmerzhitsky/yii2-seomodule": "*"
```

to the require section of your `composer.json` file. Then run command

```
php composer.phar update

```

After installation extension run migration:

```
./yii migrate --migrationPath="@vendor/nevmerzhitsky/yii2-seomodule/migrations"

```

Configuration of demisang/yii2-seo
----------------------------------

[](#configuration-of-demisangyii2-seo)

In components configuration add the following:

```
[
    'components' => [
        'seo' => [
            'class' => 'nevmerzhitsky\seomodule\Meta'
        ],
        'view' => [
            'as seo' => [
                'class' => 'nevmerzhitsky\seomodule\SeoViewBehavior',
            ]
        ],
    ],
    ...
];
```

And add SEO extension to bootstrap:

```
'bootstrap' => ['log', 'seo']
```

In model file add seo model behavior:

```
public function behaviors()
{
    $it = $this;

    return [
        'seo' => [
            'class' => 'nevmerzhitsky\seomodule\SeoModelBehavior',
            'title' => [
                'produceFunc' => 'title',
                'produceMaxLength' => 150,
                'overrideByDb' => false
            ],
            'descriptionProduceFunc' => 'short_desc',
            'keysProduceFunc' => function ($model) {
                /* @var $model self|\yii\db\ActiveRecord */
                return $model->title . ', tag1, tag2';
            },
            'metaField' => 'seo_meta',
            'userCanEdit' => Yii::$app->has('user') && Yii::$app->user->can(User::ROLE_ADMIN),
            // 'languages' => 'ru',
            'urlField' => 'seo_url',
            'urlProduceField' => 'title',
            'controllerClassName' => '\frontend\controllers\PostController',
            'uniqueUrlFilter' => function ($query) use ($it) {
                /* @var $query \yii\db\Query */
                $query->andWhere(['category_id' => $it->category_id]);
            },
        ],
    ];
}
```

In main layout:

```

    ...

```

Usage
-----

[](#usage)

In a controller action for the model ("view" for example):

```
Yii::$app->seo->registerModel($model);
```

You can register several models in one action. If these models have 'seo' behavior, then SEO data will combined from all of them in registration order.

In admin/manager site you can add fields for editing SEO data of a model ("\_form.php" template):

```

```

Configuration and using of the Amirax/yii2-seo-tools
----------------------------------------------------

[](#configuration-and-using-of-the-amiraxyii2-seo-tools)

### SEO Meta

[](#seo-meta)

Extension will automatically load the correct row from the database using the currently running and params.You can optionally override data by specifying them in a parameter array

```
Yii::$app->seo->title = 'Page title';
Yii::$app->seo->metakeys = 'seo,yii2,extension';
Yii::$app->seo->metadesc = 'Page meta description';
Yii::$app->seo->tags['og:type'] = 'article';
```

You can set the templates for tags. For example:

```
Yii::$app->seo->setVar('USER_NAME', 'Smith');
Yii::$app->seo->tags['og:title'] = 'Hello %USER_NAME%';
```

Default variables:

- %HOME\_URL% - Homepage url
- %CANONICAL\_URL% - Canonical URL for current page
- %LOCALE% - Site locale

### SEO Redirect

[](#seo-redirect)

For enabling SEO Redirect add to configuration file

```
'errorHandler' => [
    'class' => 'nevmerzhitsky\seomodule\Redirect',
],
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1298eb016f8d48713e6267622c7a2928b31c75b525cb606fa67b6cc6d42eae7?d=identicon)[nevmerzhitsky](/maintainers/nevmerzhitsky)

---

Top Contributors

[![nevmerzhitsky](https://avatars.githubusercontent.com/u/1006042?v=4)](https://github.com/nevmerzhitsky "nevmerzhitsky (18 commits)")

### Embed Badge

![Health badge](/badges/nevmerzhitsky-yii2-seomodule/health.svg)

```
[![Health](https://phpackages.com/badges/nevmerzhitsky-yii2-seomodule/health.svg)](https://phpackages.com/packages/nevmerzhitsky-yii2-seomodule)
```

###  Alternatives

[sail/useragent

Library to detect the browser and all its info (OS, Platform, ...)

282.7k](/packages/sail-useragent)

PHPackages © 2026

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