Download the PHP package sjaakp/yii2-comus without Composer

On this page you can find all versions of the php package sjaakp/yii2-comus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii2-comus

yii2-comus

Comment Module for Yii2 PHP Framework

Latest Stable Version Total Downloads License

Comus is a complete comment module for the Yii 2.0 PHP Framework.

It lets authenticated visitors of a website place comments. The moderator, as well as the administrator of the site can accept or reject comments, either after or before they are submitted. They can also update or delete any comment. Optionally, commenters are allowed to update or delete their own comment.

Comus sports three widgets:

A demonstration of Comus is here.

Prerequisites

Comus relies on Role-Based Access Control (RBAC). Therefore, the authManager application component has to be configured. Comus works with Yii's PhpManager as well as with the DbManager.

Comus assumes that the site uses Bootstrap 4. I suppose that it will work under Bootstrap 3, but it will be a lot less pleasing to the eye.

Comus also assumes that Font Awesome 5.x is available, either the Free or the Pro version. If you're adventurous, you may adapt the icons option of the module to make Comus work with another icon font.

It is strongly advised that the app uses Pretty URLs.

Installation

Install yii2-comus in the usual way with Composer. Add the following to the require section of your composer.json file:

"sjaakp/yii2-comus": "*"

or run:

composer require sjaakp/yii2-comus

You can manually install yii2-comus by downloading the source in ZIP-format.

Module

Comus is a module in the Yii2 framework. It has to be configured in the main configuration file, usually called web.php or main.php in the config directory. Add the following to the configuration array:

   <?= $model->title ?>
   <?= $model->author ?>
   // ... more information about $model ...

   <?= Comment::widget([
        'model' => $model
   ]) ?>

Likewise in the view file for the Movie model.

In the index files we might use the CommentCount widget:

   <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            'title:text',
            [
                'value' => function ($model, $key, $index, $widget) {
                    return CommentCount::widget([ 'model' => $model ]);
                },
                'format' => 'html'  // CommentCount displays a link
            ],
            // ... more columns ...
        ],
        // ... more options ...
   ]) ?>

The site may also provide in displaying information about registered users. The view file for the User model can use the UserComments widget and may look like this:

   <?= $user->name ?>
   <?= $user->registeredSince ?>
   // ... more information about $user ...

   <?= UserComments::widget([
        'userId' => $user->id
   ]) ?>

Comment levels

A comment directly on a subject is said to be of level 0. A comment on such comment is said to be a reply or a comment of level 1. And so on. The maximum level of a comment is settable in the module configuration. Default is 0, meaning that only direct comments are possible. Don't set the maximum level to high, if only because each level indents somewhat.

Notice that if the moderator deletes a comment, all of its replies are deleted as well.

Comment block as seen by guest user

Comments by moderators are distinguished by a light background color. Guest is not able to issue a comment, she should login first.

Comment block as seen by authenticated user

His own comments have a light cyan background color. Hovering over a comment shows a button to issue a reply on it (if maxLevel > 0).

Comment block as seen by moderator

Content of rejected comments is readable. Hovering over a comment shows several buttons to manage it.

Buttons

From left to right:

Permissions

Comus defines a few Permissions. They are:

Name Description
createComment Issue a comment
updateComment Update a comment
deleteComment Delete a comment
updateOwnComment Update self-created comment
deleteOwnComment Delete self-created comment
manageComments Accept or reject comments

One Role is defined: moderator. Associated Permissions are updateComment, deleteComment, and manageComments.

If the site sports a Role admin, the Role moderator is included.

Only moderators are allowed to view the comments overview, on URL:

example.com/comment

From there, they can easily jump to pending records, waiting to be accepted or rejected.

Notice that in the default configuration, Comus allows all authenticated users to create comments, and it's not necessary to explicitly give them permission. The createComment Permission is for scenarios where you want to restrict the allowance to issue comments.

Module options

The Comus module has a range of options. They are set in the application configuration like so:

 <?php
 // ...
 'modules' => [
     'comment' => [
         'class' => 'sjaakp\comus\Module',
         'maxLevel' => 2,
         // ...
         // ... more options ...
     ],
 ],
 // ...

The options (most are optional) are:

Comment Options

The Comment widget has three options:

CommentCount Options

The CommentCount widget has four options:

UserComments Options

The UserComments widget has two options:

UserComments is derived from Yii's GridView, so it has al the options belonging to that class as well.

Events

Comus doesn't define Events of it's own. However, a Comment is just an ordinary ActiveRecord and you can use it's Events to intercept comment events and inject your own code. Refer to the file 'ComusEvents.php' for a possible approach.

Internationalization

All of Comus' utterances are translatable. The translations are in the 'sjaakp\comus\messages' directory.

You can override Comus' translations by setting the application's message source in the main configuration, like so:

 <?php
 // ...
 'components' => [
     // ... other components ...     
     'i18n' => [
          'translations' => [
               // ... other translations ...
              'comus' => [    // override comus' standard messages
                  'class' => 'yii\i18n\PhpMessageSource',
                  'basePath' => '@app/messages',  // this is a default
                  'sourceLanguage' => 'en-US',    // this as well
              ],
          ],
     ],
     // ... still more components ...
 ]

The translations should be in a file called 'comus.php'.

If you want a single or only a few messages translated and use Comus' translations for the main part, the trick is to set up 'i18n' like above and write your translation file something like:

  <?php
  // app/messages/nl/comus.php

  $comusMessages = Yii::getAlias('@sjaakp/comus/messages/nl/comus.php');

  return array_merge (require($comusMessages), [
     'Empty' => 'Leeg',   // your preferred translation
  ]);

At the moment, the only language implemented is Dutch. Agreed, it's only the world's 52th language, but it happens to be my native tongue. Please, feel invited to translate Comus in other languages. I'll be more than glad to include them into Comus' next release.

Override view-files

Comus' view files can be overridden. Just set the views setting of the module to something like:

 <?php
 // ...
 'modules' => [
     'comment' => [
         'class' => 'sjaakp\comus\Module',
         'views' => [
              'default' => [    // Comus controller id
                  'user' => <view file>    // action => view
              ]
         ],
         // ...
         // ... more options ...
     ],
 ],
 // ...

<view file> can be of any form [yii\web\controller::render()](https://www.yiiframework.com/doc/api/2.0/yii-base-controller#render()-detail "Yii2") accepts.

Module ID

By default, the Module ID is 'comment'. It is set in the module configuration. If necessary (for instance if there is a conflict with another module or application component), you may set the Module ID to something different. Important: in that case, the moduleId property of the Comment and CommentCount widgets must be set to this new value as well.

Comus?

Comus is the ancient Greek god of festivity and revelry. He is the son of Dionysus and is associated with anarchy and chaos. That, and the fact that his name starts with 'com', to me makes Comus a good name for a comment module.


All versions of yii2-comus with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
yiisoft/yii2 Version ~2.0.14
sjaakp/yii2-novelty Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sjaakp/yii2-comus contains the following files

Loading the files please wait ....