承接 laravel-enso/action-logger 相关项目开发

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

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

laravel-enso/action-logger

Composer 安装命令:

composer require laravel-enso/action-logger

包简介

User actions logger dependency for Laravel Enso

README 文档

README

License Stable Downloads PHP Issues Merge Requests

Description

Action Logger records authenticated user activity for routes that opt into Enso's action-logger middleware.

It is a small backend package focused on request auditing at the application edge. It captures which authenticated user accessed which named route, by which HTTP method, at what URL, and how long the request took to complete.

The package is designed to work inside the Laravel Enso ecosystem and integrates with Enso users, permissions, dynamic relationships, frontend enums, and Enso tables.

Installation

This package comes pre-installed in Laravel Enso distributions that require activity tracking.

For standalone package installation inside an Enso-based application:

composer require laravel-enso/action-logger

The package auto-registers its service provider, loads its migrations, and registers the action-logger middleware alias.

Run the migrations after installation:

php artisan migrate

Features

  • Registers the action-logger route middleware alias.
  • Creates and maintains the action_logs table through package migrations.
  • Persists one log entry per authenticated request handled by the middleware.
  • Stores user_id, url, route, numeric method, duration, and timestamps for each action.
  • Exposes REST methods through the frontend-ready Methods enum.
  • Adds a dynamic actionLogs() relationship to the Enso User model.
  • Exposes an ActionLog model with user() and permission() relationships.
  • Links logged route names back to Enso permissions through the permission() relation.
  • Provides the System > Action Logs table structure, with user, method, permission, URL, duration and creation datetime columns.
  • Sorts the action logs table by newest entries first.
  • Formats request duration as a numeric column with three decimal places.
  • Keeps permissions as the route-facing table surface while the raw route value remains an internal storage detail.

Usage

Apply the middleware to the routes you want to track:

Route::middleware(['web', 'auth', 'action-logger'])
    ->group(function (): void {
        Route::get('/administration/users/{user}', UserController::class)
            ->name('administration.users.show');
    });

Once the middleware is active, every authenticated request matched by those routes will create a new action log entry when the request terminates.

The package also adds an actionLogs() relationship to the Enso user model, so user activity can be queried directly:

$logs = $user->actionLogs()
    ->latest()
    ->get();

API

Middleware

  • Alias: action-logger
  • Class: LaravelEnso\ActionLogger\Http\Middleware\ActionLogger
  • Behavior: creates the log entry in terminate(), after the response is sent

Model

LaravelEnso\ActionLogger\Models\ActionLog

Stored attributes:

  • user_id
  • url
  • route
  • method
  • duration
  • created_at
  • updated_at

method is cast to LaravelEnso\ActionLogger\Enums\Methods.

Relationships:

  • user() Belongs to LaravelEnso\Users\Models\User
  • permission() Belongs to LaravelEnso\Permissions\Models\Permission using route -> name

Dynamic User Relation

The package binds an actionLogs() relation to LaravelEnso\Users\Models\User through the Enso dynamic-methods package.

Enum

LaravelEnso\ActionLogger\Enums\Methods

Registered frontend key:

  • actionLogMethods

Supported methods:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
  • OPTIONS
  • HEAD

Use Methods::fromRequest($request) to map an internal Laravel request to the stored enum value.

Table

Backend route group:

  • Prefix: api/system/actionLogs
  • Route names: system.actionLogs.*

Available endpoints:

  • system.actionLogs.initTable
  • system.actionLogs.tableData
  • system.actionLogs.exportExcel

The companion frontend package is @enso-ui/action-logger.

The table defaults to action_logs.created_at desc, exposes created_at as a datetime column, and displays the resolved permission instead of a separate raw route column.

::: warning Note This package only logs actions for authenticated requests. If no authenticated user is available, no action log entry is created.

Because it relies on the resolved route name, routes without meaningful names provide less useful audit data. :::

Depends On

Required Enso packages:

Framework dependency:

  • Laravel 12 compatible application stack

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

laravel-enso/action-logger 适用场景与选型建议

laravel-enso/action-logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43.8k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2019 年 05 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「logging」 「laravel-enso」 「action-logger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 laravel-enso/action-logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 laravel-enso/action-logger 我们能提供哪些服务?
定制开发 / 二次开发

基于 laravel-enso/action-logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 43.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 29
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 4
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-16