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

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

drtsb/yii2-seo
==============

Yii2 SEO module.

0.4.1(6y ago)287[1 PRs](https://github.com/drtsb/yii2-seo/pulls)MITPHPPHP &gt;=5.6.0

Since Mar 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/drtsb/yii2-seo)[ Packagist](https://packagist.org/packages/drtsb/yii2-seo)[ Docs](https://github.com/drtsb/yii2-seo)[ RSS](/packages/drtsb-yii2-seo/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (7)Versions (7)Used By (0)

yii2-seo
========

[](#yii2-seo)

Yii2 SEO module

[![Latest Stable Version](https://camo.githubusercontent.com/945628b683ef0ade631285eaf017158925f1b43e0ccec2b07a0f0ffa80f9cf46/68747470733a2f2f706f7365722e707567782e6f72672f64727473622f796969322d73656f2f762f737461626c65)](https://packagist.org/packages/drtsb/yii2-seo) [![Total Downloads](https://camo.githubusercontent.com/d9051486a5a83c1ebf4d44728edd03e019b0f84b2c1d191d8c5533f47b2a7363/68747470733a2f2f706f7365722e707567782e6f72672f64727473622f796969322d73656f2f646f776e6c6f616473)](https://packagist.org/packages/drtsb/yii2-seo) [![License](https://camo.githubusercontent.com/ee2f1cf75461ea1844982b11dd6ba4fd886f2207b39d133dc43406e6d63a4cda/68747470733a2f2f706f7365722e707567782e6f72672f64727473622f796969322d73656f2f6c6963656e7365)](https://packagist.org/packages/drtsb/yii2-seo) [![Build Status](https://camo.githubusercontent.com/3f5516f31cf5ff4691ca6d7833170bdf4f086c4629532b7044e4bf09e441d31d/68747470733a2f2f7472617669732d63692e6f72672f64727473622f796969322d73656f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/drtsb/yii2-seo)

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

[](#installation)

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

Either run

```
composer require drtsb/yii2-seo:*

```

or add

```
"drtsb/yii2-seo" : "*"
```

to the require section of your application's `composer.json` file.

Usage
-----

[](#usage)

The extension consists of 2 parts:

- **Module** provides a simple CRUD to edit SEO params for pages specified by controller and action.
- **ModelBehavior** adds SEO fields to specific model.

First of all, you need to apply migrations

```
yii migrate --migrationPath=@vendor/drtsb/yii2-seo/src/migrations

```

or use [namespaced migrations](https://www.yiiframework.com/doc/guide/2.0/en/db-migrations#namespaced-migrations) and add

```
'controllerMap' => [
    ...
    'migrate' => [
        'class' => 'yii\console\controllers\MigrateController',
        'migrationNamespaces' => [
            'drtsb\yii\seo\migrations',
        ],
    ],
    ...
],
```

to your apllication config file.

### Module configuration

[](#module-configuration)

```
'modules' => [
	...
    'seo' => [
        'class' => 'drtsb\yii\seo\Module',
        'accessRoles' => ['admin'], // Default: null
        'pagination' => ['pageSize' => 10], // Default: false
    ],
    ...
],
```

After that, you can manage your SEO by accessing `/seo/default`

You can use **\*** mask at **Controller** and **Action** fields For example, for page **site/index** will be used first appropriate row in following order:

OrderControllerActionTitleMeta Description1siteindexTitle for site/index...2site\*Title for any action of site controller...3\*indexTitle for index action of any controller...4\*\*Title for any action of any controller...Add behavior to your frontend controller

```
use drtsb\yii\seo\behaviors\SeoBehavior;

public function behaviors()
{
    return [
        SeoBehavior::class,
    ];
}
```

### Working with models

[](#working-with-models)

Add behavior to your model

```
public function behaviors()
{
    return [
        'seo' => [
            'class' => 'drtsb\yii\seo\behaviors\SeoModelBehavior',
        ],
    ];
}
```

add to model's form

```

```

Register meta tags at frontend view

```
use drtsb\yii\seo\widgets\MetaTagsWidget;

MetaTagsWidget::widget(['view' => $this, 'model' => $model]);
```

You can also generate SEO values depending on model's attributes using **dataClosure** param

```
public function behaviors()
{
    return [
        'seo' => [
            'class' => 'drtsb\yii\seo\behaviors\SeoModelBehavior',
            'dataClosure' => function($model) {
                return [
                    'meta_title' => $model->title . ' Title',
                    'meta_description' => $model->title . ' Description',
                    'meta_keywords' => $model->title . ' Keywords',
                    'meta_noindex' => true,
                    'meta_nofollow' => true,
                    'rel_canonical' => 'site/index', // or 'http://some.site'
                    'dont_use_empty' => true, // Default value false
                ];
            },
        ],
    ];
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.9% 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 ~102 days

Total

5

Last Release

2201d ago

### Community

Maintainers

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

---

Top Contributors

[![drtsb](https://avatars.githubusercontent.com/u/11088965?v=4)](https://github.com/drtsb "drtsb (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

yii2extensionmoduleyiiseoyii 2

###  Code Quality

TestsCodeception

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/drtsb-yii2-seo/health.svg)

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

PHPackages © 2026

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