PHPackages                             skeeks/cms-comments - 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. [Framework](/categories/framework)
4. /
5. skeeks/cms-comments

ActiveYii2-extension[Framework](/categories/framework)

skeeks/cms-comments
===================

Comments component

1.2.2(1y ago)053BSD-3-ClausePHP

Since Dec 30Pushed 1y ago2 watchersCompare

[ Source](https://github.com/skeeks-cms/cms-comments)[ Packagist](https://packagist.org/packages/skeeks/cms-comments)[ Docs](http://skeeks.com/)[ RSS](/packages/skeeks-cms-comments/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (9)Used By (0)

Comments
========

[](#comments)

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist skeeks/cms-comments "*"

```

or add

```
"skeeks/cms-comments": "*"

```

- Run migrations

```
yii migrate --migrationPath=@skeeks/cms/comments/migrations/
```

How to use (simple)
-------------------

[](#how-to-use-simple)

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

[](#configuration)

- In your config file

```
'bootstrap' => ['comments'],
'components' =>
[
'i18n' => [
    'translations'  =>
    [
        'skeeks/comments' =>
        [
            'class'             => 'yii\i18n\PhpMessageSource',
            'basePath'          => '@skeeks/cms/comments/messages',
            'fileMap' => [
                'skeeks/comments' => 'main.php',
            ],
        ]
    ],
],
],

'modules' =>
[
	'comments' =>
	[
	    'class' => 'skeeks\cms\comments\CommentsModule',
	    //'maxNestedLevel'          => 5
        //'onlyRegistered'          => false
        //'orderDirection'          => SORT_DESC
        //'nestedOrderDirection'    => SORT_ASC
        //'displayAvatar'           => true
        //'commentsPerPage'         => 5,
        'on commentAdded' => function(\skeeks\cms\comments\events\CommentEvent $e)
        {
            /**
             * @var $comment \skeeks\cms\comments\models\CmsComment
             */
            $comment = $e->comment;
            $comment->user;
            $comment->model;
            $comment->model_id;
        },

        'on commentDeleted' => function(\skeeks\cms\comments\events\CommentEvent $e)
        {
            //...
        }
	]
]
```

- In you model \[optional\]

```
public function behaviors()
{
  return [
    'comments' => [
      'class' => 'skeeks\cms\comments\behaviors\CommentsBehavior'
    ]
  ];
}
```

- Content element property update count comments

```
'on commentAdded' => function(\skeeks\cms\comments\events\CommentEvent $e)
{
	/**
	 * @var $comment \skeeks\cms\comments\models\CmsComment
	 * @var $user \common\models\User
	 * @var $element \skeeks\cms\models\CmsContentElement
	 */
	$comment = $e->comment;
	$user = $comment->user;

	/*$user->appUser->total_comments = $user->appUser->total_comments + 1;
	if (!$user->appUser->save())
	{
	    \Yii::error("Not update user total comments: {$user->id}", 'project');
	}*/

	\Yii::error(\skeeks\cms\models\CmsContentElement::tableName(), 'project');
	\Yii::error(\yii\helpers\Json::encode($comment->toArray()), 'project');

	if ($comment->model == \skeeks\cms\models\CmsContentElement::tableName())
	{
	    $element = \skeeks\cms\models\CmsContentElement::findOne($comment->model_id);
	    if ($element && $element->relatedPropertiesModel->hasAttribute('comments'))
	    {
		$totalComments = \skeeks\cms\comments\models\CmsComment::find()->where([
		    'model_id' => $element->id,
		])->andWhere(['model' => \skeeks\cms\models\CmsContentElement::tableName()])->count();
		$element->relatedPropertiesModel->setAttribute('comments', $totalComments);
		//$element->relatedPropertiesModel->setAttribute('comments', ((int) $element->relatedPropertiesModel->getAttribute('comments') + 1));

		if (!$element->relatedPropertiesModel->save())
		{
		    \Yii::error("Not update element total comments: {$element->id}", 'project');
		}
	    } else
	    {
		\Yii::error("Element not found or not have property comments: {$element->id}", 'project');
	    }
	}
},

'on commentDeleted' => function(\skeeks\cms\comments\events\CommentEvent $e)
{
....

```

Usage
-----

[](#usage)

- Widget namespace

```
use skeeks\cms\comments\widgets\CommentsWidget;
```

- Add comment widget in model view using (string) page key :

```
echo Comments::widget(['model' => $pageKey]);
```

- Or display comments using model name and id:

```
echo Comments::widget(['model' => 'post', 'model_id' => 1]);
```

- Or display comments using model behavior:

```
echo Post::findOne(10)->displayComments();
```

Module Options
--------------

[](#module-options)

Use this options to configurate comments module:

- `userModel` - User model class name.
- `maxNestedLevel` - Maximum allowed nested level for comment's replies.
- `onlyRegistered` - Indicates whether not registered users can leave a comment.
- `orderDirection` - Comments order direction.
- `nestedOrderDirection` - Replies order direction.
- `userAvatar` - The field for displaying user avatars.

    Is this field is NULL default avatar image will be displayed. Also it can specify path to image or use callable type.

    If this property is specified as a callback, it should have the following signature: `function ($user_id)`

For dev
-------

[](#for-dev)

```
php yii lang/translate-app @skeeks/cms/comments/messages/ru/main.php @skeeks/cms/comments/messages/ main.php
```

---

> [![skeeks!](https://camo.githubusercontent.com/cae82dcf01ec5dead3fe52f7d6dc919d52b7b060cdaccddb39a7a4c3383a282f/68747470733a2f2f67726176617461722e636f6d2f75736572696d6167652f37343433313133322f31336430346438333231383539333536343432323737306236313665353632322e6a7067)](http://skeeks.com)
> *SkeekS CMS (Yii2) — fast, simple, effective!*
> [skeeks.com](http://skeeks.com) | [cms.skeeks.com](http://cms.skeeks.com) | [marketplace.cms.skeeks.com](http://marketplace.cms.skeeks.com)

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance47

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity68

Established project with proven stability

 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 ~438 days

Recently: every ~579 days

Total

8

Last Release

399d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/785306737dd13e3ea6826dfc04ab29ececa88f560d054ff595d64853cb878219?d=identicon)[skeeks-semenov](/maintainers/skeeks-semenov)

---

Top Contributors

[![skeeks-semenov](https://avatars.githubusercontent.com/u/9209305?v=4)](https://github.com/skeeks-semenov "skeeks-semenov (31 commits)")

---

Tags

commentsskeeksskeeks-cmsskeekscmsyiiyii2yii2-extensionframeworkappSxskeeksyiicomments

### Embed Badge

![Health badge](/badges/skeeks-cms-comments/health.svg)

```
[![Health](https://phpackages.com/badges/skeeks-cms-comments/health.svg)](https://phpackages.com/packages/skeeks-cms-comments)
```

###  Alternatives

[skeeks/yii2-assets-auto-compress

Automatically compile and merge files js + css + html in yii2 project

157453.5k6](/packages/skeeks-yii2-assets-auto-compress)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13725.7k53](/packages/skeeks-cms)[skeeks/cms-shop

Интернет магазин для SkeekS CMS

145.6k22](/packages/skeeks-cms-shop)

PHPackages © 2026

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