secretwebmaster/wncms-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

secretwebmaster/wncms-api

Composer 安装命令:

composer require secretwebmaster/wncms-api

包简介

WNCMS API management and usage logging package

README 文档

README

Extend the function of core WNCMS API. Allow multiple API token per user.

This package does not replace the core WNCMS API.
Instead, it adds extra features on top of the existing API layer, mainly focused on token management and usage logging.

Features

  • Multiple API tokens per user
  • Backend UI to create, edit, test, and revoke tokens
  • Per-token name, remark, and expiration support (depending on your implementation)
  • API token validation middleware (ValidateApiToken)
  • API usage logging to a dedicated table
  • Async logging via LogApiUsageJob
  • Backend API logs index with filters and pagination
  • Dashboard widget to display recent API usage

Requirements

  • WNCMS core installed and working
  • Laravel version compatible with your WNCMS core (for example Laravel 11)
  • Queue worker configured if you want to process LogApiUsageJob asynchronously

Installation

Install via Composer:

composer require secretwebmaster/wncms-api

In WNCMS, go to the backend package / module management and activate the wncms-api package. Migrations and basic setup will be handled by WNCMS according to your core design.

Configuration

The package uses config/wncms-api.php.

Typical options include:

  • Global enable/disable of extended API features
  • Whether to log all requests using ValidateApiToken
  • Default log retention / cleanup strategy (if implemented)

You can adjust these options in your main project config/wncms-api.php as needed.

Usage

1. Multiple tokens per user

Go to:

Backend => API Tokens

From there you can:

  • Create tokens for any user
  • Set token name, remark, and optional expiration
  • Copy token value for client usage
  • Revoke tokens when no longer needed

Each user can hold multiple active tokens at the same time.

2. Protect routes with API token middleware

In your main application, you can attach the middleware to routes or groups (if not already done by WNCMS core):

Route::middleware(['api', 'wncms.api_token'])->group(function () {
    // Your protected API routes
});

ValidateApiToken will:

  • Read token from Authorization: Bearer {token} or other sources you defined
  • Validate against api_tokens table
  • Optionally dispatch LogApiUsageJob to store logs

3. API usage logs

Go to:

Backend => API Logs

You can:

  • View requests using each token
  • Filter by user, token, method, or path (depending on implementation)
  • Use this for debugging and basic security auditing

4. Dashboard widget

After installing and activating this package, the backend dashboard may show a widget named like:

API Usage

It can display:

  • Recent request count
  • Simple charts or stats (depending on your Blade implementation)

Development notes

This package is designed only to extend the existing WNCMS core API layer:

  • Core API controllers and routes remain inside wncms-core

  • wncms-api focuses on:

    • token management UI
    • middleware-level token validation
    • usage logging
    • dashboard / reports

You can safely customize views and translations in your project if you need a different UI or language.

License

This package follows the same license as the main WNCMS project (for example, MIT), unless specified otherwise in the repository.

secretwebmaster/wncms-api 适用场景与选型建议

secretwebmaster/wncms-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 secretwebmaster/wncms-api 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-13