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

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

kovenant/yii2-seo-components
============================

Seo components for Yii 2

1.1.0(5y ago)21701MITPHPPHP &gt;=5.6.0CI failing

Since Aug 1Pushed 5y agoCompare

[ Source](https://github.com/kovenant/yii2-seo-components)[ Packagist](https://packagist.org/packages/kovenant/yii2-seo-components)[ Docs](https://github.com/kovenant/yii2-seo-components)[ RSS](/packages/kovenant-yii2-seo-components/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

yii2-seo-components
===================

[](#yii2-seo-components)

[![Latest Version](https://camo.githubusercontent.com/30fe72c4b30389c2193f9fcaeb1833d762f52dd7956d282ae5fc044e84a8675b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6f76656e616e742f796969322d73656f2d636f6d706f6e656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kovenant/yii2-seo-components)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/499ee7a2f6ac241695f35cce01929741ed46dda91f099770f8235dfd3c00bc17/68747470733a2f2f7472617669732d63692e636f6d2f6b6f76656e616e742f796969322d73656f2d636f6d706f6e656e74732e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/kovenant/yii2-seo-components)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/98b53eb29e4bfc1836c86f63b6feadd25cc8dccc2badd1282ededc865f02be24/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6f76656e616e742f796969322d73656f2d636f6d706f6e656e74732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kovenant/yii2-seo-components/?branch=master)[![codecov](https://camo.githubusercontent.com/44cb09e8c06109ff18aa2481ef89deb4ab9220eb065162e8abfa77f750a63884/68747470733a2f2f636f6465636f762e696f2f67682f6b6f76656e616e742f796969322d73656f2d636f6d706f6e656e74732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/kovenant/yii2-seo-components)

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist kovenant/yii2-seo-components "*"

```

or add this code line to the `require` section of your `composer.json` file:

```
"kovenant/yii2-seo-components": "*"
```

SeoModelBehavior Usage
----------------------

[](#seomodelbehavior-usage)

Add SeoModelBehavior to your model

{id}, {category\_id} and {alias} will be replaced by the value of the attributes of the current model, that have such names

{category.alias} will be replaced by the value of the relation’s attribute

```
    /**
     * @return array
     */
    public function behaviors()
    {
        return [
            [
                'class' => \kovenant\seo\SeoModelBehavior::class,
                'route' => ['catalog/item', 'categoryId' => '{category_id}', 'categoryAlias' => '{category.alias}', 'id' => '{id}', 'alias' => '{alias}']
            ],
        ];
    }
```

Behavior provides three methods:

- `$model->getRouteUrl()`will return route as array. Now you can use it for yii\\widgets\\Menu items 'url'

```
Array
(
    [0] => catalog/item
    [categoryId] => 1
    [categoryAlias] => category-alias
    [id] => 5
    [alias] => item-alias
)

```

- `$model->getUrl()` will return for example `/catalog/1-category-alias/5-item-alias.html`
- `$model->getAbsoluteUrl()` returns `https://example.com/catalog/1-category-alias/5-item-alias.html`

Don't forget to check your config file for pretty url settings

E.g.

```
    'components' => [
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'suffix' => '.html',
            'rules' => [
                'catalog/-/-' => 'catalog/item',
            ],
        ],
    ],
```

MetaTagsWidget.php Usage
------------------------

[](#metatagswidgetphp-usage)

Add MetaTagsWidget to your view

```
/** yii\db\ActiveRecord $model */
\kovenant\seo\MetaTagsWidget::widget(['component' => $model]);
```

In addition to the widget settings you can configure common widget options via container definitions in your config file

Example of full options:

```
    'container' => [
        'definitions' => [
            'kovenant\seo\MetaTagsWidget' => [
                // set view attributes
                'viewH1Attribute' => 'h1', /* use  in your view/layout */
                'viewTitleAttribute' => 'title', /* will produce  */

                // Set the model attributes
                'componentNameAttribute' => 'name', // default name attribute (e.g. for link name)
                'componentH1Attribute' => 'h1', // h1 for page
                'componentTitleAttribute' => 'title', // meta title
                'componentKeywordsAttribute' => 'keywords', // meta keywords
                'componentDescriptionAttribute' => 'description', // meta description

                // set pager params
                'pageText' => 'Страница', // page text [Page for default]
                'pageParam' => 'page', // get param for current page

                // In all templates placeholder {text} is an original value
                'templateH1' => '{text}',
                'templateTitle' => '{text}{pager} | {appName}', // {appName} will add name of application
                'templateKeywords' => '{text}',
                'templateDescription' => '{text}{pager}', // {pager} will be replaced with text about current page
                'templatePager' => ' - {pageText} {pageValue}', // template for such replacement

                // method from \kovenant\seo\SeoModelBehavior that will return absolute url for the page of this record
                'absoluteUrlMethod' => 'getAbsoluteUrl'
            ]
        ],
    ],
    'view' => [
        //you can use custom view for h1 support
        'class' => 'kovenant\seo\SeoView',
    ],
```

`componentNameAttribute` is required. Other component attributes are optional.

The text for default value of title and description is `componentNameAttribute`.

If `viewH1Attribute` and `componentH1Attribute` are set they will be used as a default value.

`componentTitleAttribute`, `componentKeywordsAttribute` and `componentDescriptionAttribute` will set corresponding meta tags.

i.e. default value = `componentNameAttribute` &lt;&lt; `componentH1Attribute` &lt;&lt; `componentTitleAttribute`

---

If you set `absoluteUrlMethod` from SeoModelBehavior and current page of widget != absolute url from model, canonical link tag will be added.

---

You can inherit from MetaTagsWidget and add your own getters to use in templates, like {appName} and {pager}

---

See more examples of usage in tests.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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.

###  Release Activity

Cadence

Every ~6 days

Total

3

Last Release

2099d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/743ff283d8896b8a05736be128e1e35dfddda79c39357d59625f471edd8084dc?d=identicon)[kovenant](/maintainers/kovenant)

---

Top Contributors

[![kovenant](https://avatars.githubusercontent.com/u/3716657?v=4)](https://github.com/kovenant "kovenant (13 commits)")

---

Tags

yii2extensionBehaviorseo

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sjaakp/yii2-taggable

Manage tags of ActiveRecord in Yii2.

3030.6k](/packages/sjaakp-yii2-taggable)[mdmsoft/yii2-autonumber

Auto number extension for the Yii framework

1830.9k](/packages/mdmsoft-yii2-autonumber)[umanskyi31/opengraph

Created a new component for Yii2. The Open Graph component for your website

119.7k](/packages/umanskyi31-opengraph)[amirax/yii2-seo-tools

SEO tools for Yii 2 framework

131.1k](/packages/amirax-yii2-seo-tools)

PHPackages © 2026

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