定制 codesignificant/api-pro 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

codesignificant/api-pro

最新稳定版本:v1.0.1

Composer 安装命令:

composer create-project codesignificant/api-pro

包简介

API PRO – Lightweight PHP REST API framework

README 文档

README

ApiPro

ApiPro is a lightweight, production-ready PHP API framework designed for structured service-based applications.

It provides:

Deterministic pagination (including grouped queries)

UUID-first schema design

Structured API responses

Strict file upload handling

Safe storage for generated files

Service-driven architecture

Microservice-ready foundation

Installation

Install via Composer:

composer require your-vendor/apipro

Requirements:

PHP 8.1+

MySQL / MariaDB

ext-curl (recommended)

Core Concepts

  1. Structured Responses

All endpoints return a consistent response structure:

return new DataSuccess("Message", $data); return new DataFailed("Error message");

Example response:

{ "success": true, "message": "Fetched successfully", "data": { ... } }

  1. UUID-First Database Design

All tables use UUID as primary key:

id CHAR(36) NOT NULL DEFAULT uuid()

Benefits:

Distributed-safe

Microservice-friendly

No auto-increment conflicts

Horizontally scalable

  1. Pagination (Deterministic & Group-Safe)

ApiPro provides production-grade pagination:

ProSql::FetchPaginated( $table, $columns, $where, $page, $orderBy, $pageSize );

Supports:

JOIN queries

GROUP BY queries

Subqueries

Deterministic ordering

Custom counters

Order direction convention:

['+created_at'] // DESC ['-created_at'] // ASC

Grouped pagination is handled safely to prevent duplicate counts.

  1. File Handling Upload Files (HTTP only) Files::save($_FILES['file'], "/storage/images");

Features:

Strict is_uploaded_file() validation

Safe directory creation

Unique naming

Size reporting

Store Generated Files (Exports, Reports) Files::storage($absolutePath, "/exports/reports");

Used for:

Excel exports

CSV reports

Background-generated files

Upload and generated file flows are intentionally separated for security and correctness.

  1. Service-Based Architecture

Each module follows a service structure:

class ProductService {

public function fetch($node) {}
public function create($node) {}
public function update($node) {}
public function setup($node) {}

}

Responsibilities:

setup() → schema creation

fetch() → paginated listing

create() → insert logic

update() → modification logic

Example Use Cases

ApiPro is suitable for:

E-commerce platforms

Variant-based product filtering

RGB color nearest search

Cart and order management

Seller onboarding systems

Invoice generation

Export automation

Logging systems

Safe Schema Setup Pattern public function setup($node) { ProSql::Query(" CREATE TABLE IF NOT EXISTS products ( id CHAR(36) NOT NULL DEFAULT uuid(), PRIMARY KEY(id), title VARCHAR(255) NOT NULL ) ");

return new DataSuccess("Table ready");

}

Supports:

Force recreate mode

Idempotent table creation

Production-safe migrations

Security Model

No file path leakage

Strict upload validation

No bypass of is_uploaded_file

Escaped SQL inputs

Explicit API failure handling

Suggested Project Structure app/ ├── Services/ │ ├── ProductService.php │ ├── OrderService.php │ ├── SellerService.php │ └── LogService.php ├── Core/ │ ├── ProSql.php │ ├── Files.php │ └── DataResponse.php

Best Practices

Always use FetchPaginated for listings

Use UUID everywhere

Keep upload and storage flows separate

Validate external API status responses

Use grouped pagination correctly

Roadmap

Background job support

Queue system

Token-based file downloads

Validation layer

Rate limiting

Module scaffolding

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固