rashidsiaghi/laravel-activitylog
Composer 安装命令:
composer require rashidsiaghi/laravel-activitylog
包简介
Custom activity log system based on Spatie Laravel Activitylog
README 文档
README
This package is a customized activity logging system for Laravel, extending and modifying the excellent Spatie Laravel Activitylog.
✅ Features
- Logs model attributes, including nested and relationship changes.
- Adds tracking for device info, IP address, browser, and user role.
- Customizable pipelines and event descriptions.
- Built-in support for
hasMany,belongsToMany, andmorphManyrelationships.
📦 Based On
Log activity inside your Laravel app
The rashidsiaghi/laravel-activitylog package provides easy to use functions to log the activities of the users of your app. It can also automatically log model events.
The Package stores all activity in the activity_log table.
Here's a demo of how you can use it:
activity()->log('Look, I logged something');
You can retrieve all activity using the rashidsiaghi\Activitylog\Models\Activity model.
Activity::all();
Here's a more advanced example:
activity() ->performedOn($anEloquentModel) ->causedBy($user) ->withProperties(['customProperty' => 'customValue']) ->log('Look, I logged something'); $lastLoggedActivity = Activity::all()->last(); $lastLoggedActivity->subject; //returns an instance of an eloquent model $lastLoggedActivity->causer; //returns an instance of your user model $lastLoggedActivity->getExtraProperty('customProperty'); //returns 'customValue' $lastLoggedActivity->description; //returns 'Look, I logged something'
Here's an example on event logging.
$newsItem->name = 'updated name'; $newsItem->save(); //updating the newsItem will cause the logging of an activity $activity = Activity::all()->last(); $activity->description; //returns 'updated' $activity->subject; //returns the instance of NewsItem that was saved
Calling $activity->changes() will return this array:
[ 'attributes' => [ 'name' => 'updated name', 'text' => 'Lorum', ], 'old' => [ 'name' => 'original name', 'text' => 'Lorum', ], ];
Attribution
This activity logging system is based on rashidsiaghi Laravel Activitylog, released under the MIT License.
Modifications have been made to support relationship logging, trait extension, and additional device/user context features.
This code is derived from and heavily inspired by spatie/laravel-activitylog, originally created by Spatie.
We thank the Spatie team for their excellent work, which serves as the foundation of this customized version.
Installation
You can install the package via composer:
composer require rashidsiaghi/laravel-activitylog
The package will automatically register itself.
You can publish the migration with:
php artisan vendor:publish --provider="RashidSiaghi\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
Note: The default migration assumes you are using integers for your model IDs. If you are using UUIDs, or some other format, adjust the format of the subject_id and causer_id fields in the published migration before continuing.
After publishing the migration you can create the activity_log table by running the migrations:
php artisan migrate
You can optionally publish the config file with:
php artisan vendor:publish --provider="RashidSiaghi\Activitylog\ActivitylogServiceProvider" --tag="activitylog-config"
Changelog
Please see CHANGELOG for more information about recent changes.
Upgrading
Please see UPGRADING for details.
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
🔒 License
This project and all modified code are released under the MIT License.
Original copyright © Spatie.
rashidsiaghi/laravel-activitylog 适用场景与选型建议
rashidsiaghi/laravel-activitylog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「log」 「user」 「laravel」 「activity」 「rashidsiaghi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rashidsiaghi/laravel-activitylog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rashidsiaghi/laravel-activitylog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rashidsiaghi/laravel-activitylog 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
Laravel 5.x.x library for integration Monolog Sentry
Pacote simplificado para persistência de logs
Collection of tools to use the full power of the Enyalius framework
Standalone replacement for php's native get_browser() function
User component for Yii2
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-11