Creating modules
If you have created a complex application part and want to use it with some degree of customization in your next project, most probably you need to create a module. In this recipe, we will see how to create an application log view module.
Getting ready
Create a new yii2-app-basic
application using the composer, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
How to do it…
Let's do some planning first.
In yii2-app-basic
with default configuration, all log entries are stored in the runtime/logs/app.log
file. We can extract all messages from this file with help of regular expressions and display them on the GridView widget. Besides, we must allow the user to configure the path to the custom log file.
Carry out the following steps:
Create the
modules/log
directory and create theModule
class with the new file option:<?php namespace app\modules\log; class Module extends \yii\base\Module { public $file = '@runtime/logs...