l0max/laravel-activity-log
Composer 安装命令:
composer require l0max/laravel-activity-log
包简介
A Laravel package to log and store user activities across the application
关键字:
README 文档
README
A simple package to log user activity in Laravel applications. Admins can view all logs, while users can view only their own logs.
Installation
You can install the package via Composer:
composer require l0max/laravel-activity-log
To publish the configuration file, run the following command:
php artisan vendor:publish --provider="L0MAX\ActivityLog\ActivityLogServiceProvider"
This will publish the config file config/activitylog.php.
Usage
Once the package is installed, you can use the activity log to track user actions. Each time an action is logged, the ActivityLog model stores the user ID and a description of the action.
Example Usage
use L0MAX\ActivityLog\ActivityLog; ActivityLog::create([ 'user_id' => auth()->id(), 'description' => 'User performed some action.', ]);
Viewing Logs
Admins can view all logs, while regular users can view only their own activity logs.
Policy
A policy is included to handle permissions for viewing logs. Here's a simple example of how to control access to activity logs:
namespace L0MAX\ActivityLog\Policies; use App\Models\User; use L0MAX\ActivityLog\ActivityLog; class ActivityLogPolicy { public function view(User $user, ActivityLog $log) { return $user->hasRole('admin') || $user->id === $log->user_id; } }
Database Migrations
To create the activity_logs table, run the migrations:
php artisan migrate
Factory
You can generate test data using the factory provided:
ActivityLog::factory()->create();
Testing
You can run the tests with:
vendor/bin/phpunit
Ensure that you have added the proper testing logic in the tests/Feature/ directory.
Customization
You can customize the package to suit your needs. The following features can be extended:
- Custom log formats
- Additional policies
Security
If you discover any security-related issues, please email ankahdonatus@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
l0max/laravel-activity-log 适用场景与选型建议
l0max/laravel-activity-log 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 「Laravel-Security」 「laravel-package」 「laravel-log」 「laravel-activity-log」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 l0max/laravel-activity-log 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 l0max/laravel-activity-log 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 l0max/laravel-activity-log 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A package to keep a history of all password changes of users
Put users, IP addresses and anonymous browser fingerprints on surveillance and block malicious ones.
Manage fishing and other optional security matters
A Laravel package for automated monitoring of security vulnerabilities and outdated packages in Composer and NPM dependencies.
Laravel package that scans applications (including Livewire) for security vulnerabilities, reports issues with severity levels, and provides remediation guidance and optional automated fixes.
Alfabank REST API integration
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-03