1. Go to this page and download the library: Download sjaakp/yii2-comus library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sjaakp / yii2-comus example snippets
// ...
'modules' => [
'comment' => [
'class' => 'sjaakp\comus\Module',
// several options
],
],
// ...
The module has to be *bootstrapped*. Do this by adding the following to the
application configuration array:
<php
// ...
'bootstrap' => [
'comment',
]
// ...
There probably already is a `bootstrap` property in your configuration file; just
add `'comment'` to it.
**Important**: the module should also be set up in the same way in the console configuration (usually
called `console.php`).
#### Console commands ####
To complete the installation, two [console commands](https://www.yiiframework.com/doc/guide/2.0/en/tutorial-console#usage "Yii2")
have to be run. The first will create a database table for the comments:
yii migrate
The migration applied is called `sjaakp\comus\migrations\m000000_000000_init`.
The second console command is:
yii comus
This will set up a role and several permissions in the RBAC-system.
## Basic usage ##
Say we have a site presenting information about books and about movies. We define
`ActiveRecord`s Book and Movie. In the `view` file for the Book model, we can use the
**Comment** widget like so:
// views/book/view.php
use sjaakp\comus\Comment;
/* @var app\models\Book $model */
// views/book/index.php
use sjaakp\comus\CommentCount;
use yii\grid\GridView;
/* @var yii\db\ActiveDataProvider $dataProvider */
// views/user/view.php
use sjaakp\comus\UserComments;
/* @var app\models\User $user */
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.