coloredcow / laravel-audit
Laravel 的审计日志
2.0.2
2019-05-06 16:06 UTC
Requires
- php: >=7.2.0
- laravel/framework: 5.8.*
This package is auto-updated.
Last update: 2024-09-03 06:07:21 UTC
README
一个用于捕获 Laravel 应用程序中系统活动的包。目前支持以下字段:
- HTTP 请求的 IP 地址,
- HTTP 引用者,
- 你想审计的操作的描述。
- 用户 ID
- 其他详细信息,如数据和键
安装
- 运行
composer require coloredcow/laravel-audit
- 将
ColoredCow\LaravelAudit\AuditServiceProvider
添加到config/app.php
'providers' => [
ColoredCow\LaravelAudit\AuditServiceProvider::class
];
- 运行
php artisan migrate
用法
- 在你想审计的事件中使用
ColoredCow\LaravelAudit\Events\Auditable
特性。并将其添加到事件的构造函数中。
$this->setAudit([
'ip' => 'ip-of-user-here',
'referer' => 'referer-address',
'action' => 'description of event and action being audited'
]);
- 使用
ColoredCow\LaravelAudit\Listeners\AuditActivities
监听器来监听你想审计的事件。在你的 Laravel 应用的 EventServiceProvider 中映射它。
审计外观
- 在你的应用程序中添加 AuditFacade 以直接从应用程序中进行审计。
AuditFacade::make(['action' => 'Audit Action']);
- 你也可以覆盖其他属性,如 IP、用户 ID 和描述。
AuditFacade::make(['action' => 'Audit Action', 'ip' => 'My IP']);