benjaminchen / TableActivityRecord by benjaminchen

table action record for lumen framework
50
0
2
Package Data
Maintainer Username: benjaminchen
Maintainer Contact: benjaminchen.c@gmail.com (benjamin)
Package Create Date: 2018-12-27
Package Last Update: 2019-01-03
Language: PHP
License: MIT
Last Refreshed: 2025-02-06 15:03:34
Package Statistics
Total Downloads: 50
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

Lumen Table Activity Record

Requirements

  • PHP >= 5.5.9
  • lumen >= 5.7
  • influxdb >= 1.7

Installation

Installation via Composer:

composer require benjamin-chen/table-activity-record

Configuration

Lumen 5.7

Add the Service Provider in bootstrap/app.php:

$app->register(BenjaminChen\TableActivityRecord\ServiceProvider::class);

Add env setting in .env:

INFLUXDB_HOST=your-influx-db-host
INFLUXDB_PORT=8086
INFLUXDB_DATABASE=your-influx-db-database

Add operate logging channel

'channels' => [
    'operate' => [
        'driver' => 'daily',
        'path' => storage_path('logs/operate/operate.log'),
    ]
],

Usage

Define model tags in model file:

class TestModel extends Model
{
    ...........

    public $tags = [
        'a', 'b', 'c'
    ];
}

Fire event after model executing create, update and delete methods

use BenjaminChen\TableActivityRecord\Events\TableActionEvent;

Event::fire(new TableActionEvent('create', $model));

Fire event will log your event data in storage/logs/operate/operate-yyyy-mm-dd.log and store the event record at influx-db.

You can use command php artisan operateRecord:check to check local log is the same with influx-db record

License

This package is open-source software and licensed under the MIT License.