承接 petritr/activity-log 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

petritr/activity-log

最新稳定版本:v1.1.0

Composer 安装命令:

composer require petritr/activity-log

包简介

Lightweight activity logging for Laravel applications

关键字:

README 文档

README

A small high-performance activity logging package for Laravel.
Easily track user actions, record model changes via polymorphic subjects, and store custom metadata. Designed for simplicity and flexibility, it supports both synchronous and asynchronous (queued) logging out of the box.

Key Features:

  • Fluent API: Log activities using a clean, readable facade.
  • Polymorphic Subjects: Link activities to any Eloquent model automatically.
  • Data Snapshots: Automatically capture specific model attributes at the time of logging.
  • Queue Support: Offload logging to background workers for better application performance.
  • Customizable: Configurable fields, silent failure options, and more.

Installation

Install via Composer:

composer require petritr/activity-log

Publish the config file:

php artisan vendor:publish --tag=activity-log-config

Run migrations:

php artisan migrate

Configuration

The package comes with a default configuration. You can customize it in config/activity-log.php.

You can also use environment variables in your .env file:

ACTIVITY_LOG_ENABLED=true
ACTIVITY_LOG_QUEUE_ENABLED=false
ACTIVITY_LOG_QUEUE=activity-logs

Config File Options:

config/activity-log.php:

return [
    // Enable/disable logging globally
    'enabled' => true,

    // Enable/disable logging via queue
    'queue_enabled' => false,
];

Usage

Using the Facade (recommended)

use Petritr\ActivityLog\Facades\ActivityLog;

// Log a simple action
ActivityLog::action('user.login')->log();

// Log with a subject
ActivityLog::action('project.updated')
    ->subject($project)
    ->log();

// Log with metadata
ActivityLog::action('order.created')
    ->withMetadata(['total' => 99.90, 'items' => ['apple', 'banana']])
    ->log();

Subject Snapshots

You can log a snapshot of any model or object:

ActivityLog::action('user.updated')
    ->subject($user)
    ->log();
    

The snapshot is stored in JSON format (subject_snapshot) in the database.

Queue Support

Enable queueing in config/activity-log.php:

'queue_enabled' => true,

Your activity will be dispatched to the queue using a Laravel Job.

License

MIT License.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固