Automatic create log for request, response, controller dan action
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist taufiqrahman/yii2-apirestlog "*"
or add
"taufiqrahman/yii2-apirestlog": "*"
to the require section of your composer.json
file.
Check your database settings and run migration from your console:
php yii migrate --migrationPath=@vendor/taufiqrahman/yii2-apirestlog/migrations
For more informations see Database Migration Documentation
Once the extension is installed, simply use it in your code by :
use Rahmansoft\Apirestlog\restlog;
class SomeController extends Controller
{
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['restlog']=
[
'class' => restlog::class,
'LOG_ON_ERROR'=> true // get all error response, false value to disable error message in your log DB
];
return $behaviors;
}
To access the module, you need to add this to your application configuration:
......
'modules' => [
'rahman'=>[
'class'=>'rahmansoft\apirestlog\Module',
],
],
......
Add the new menu item to your navbar:
......
['label' => 'Log', 'url' => ['/rahman/wslog']],
......