ufo-tech/rest-bundle 问题修复 & 功能扩展

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

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

ufo-tech/rest-bundle

最新稳定版本:1.0.0

Composer 安装命令:

composer require ufo-tech/rest-bundle

包简介

REST API bundle for building RESTful services in the UFO-Tech ecosystem.

README 文档

README

Ukraine

REST bundle for building RESTful services in the UFO-Tech ecosystem

Provides infrastructure for building REST APIs with a unified routing model, access control, and integration across UFO-Tech services.

🧬 Idea

This is an extension for JSON-RPC-BUNDLE that allows exposing a REST API based on the existing RPC infrastructure without additional configuration.

It enables fast deployment of an API layer only for the methods that must be available in the public API.

License Size package_version fork

Environment Requirements

php_version ufo-tech/rpc-bundle

⚙️ Installation

composer require ufo-tech/rpc-rest-adapter

🚦 Quick Start

After installation, the adapter automatically registers a single REST entry point that proxies requests to RPC methods.

By default, the following endpoint is used:

/rest/{path}

where {path} is the RPC route (service/method).

📡 Request Example

RPC method:

user.getList

REST request:

GET /rest/users/

POST request with parameters:

POST /rest/user/getList
{
  "page": 1,
  "limit": 20
}

⚙️ How it works

The adapter:

  • receives an HTTP REST request
  • transforms it into a JSON-RPC call
  • forwards it to JsonRpcBundle
  • returns a standard JSON response

No additional configuration is required. It is enough to add the #[Route] attribute to RPC services that must be available via the REST endpoint.

use Ufo\RpcObject\RPC;
use Symfony\Component\Routing\Attribute\Route;

#[RPC\Info(alias: 'User')]
#[Route('/users', name: 'users')]
class UserProcedure implements IRpcService
{
    #[Route('/', name: 'create', methods: ['POST'])]
    public function create(
        #[RPC\Assertions([
            new Assert\NotBlank(),
        ])]
        string $role,
        #[RPC\Assertions([
            new Assert\NotBlank(),
            new Assert\Regex(
                pattern: '/^\+380\d{9}$/', message: 'The phone number is not a valid UA mobile number'
            ),
        ])]
        string $phone,
        #[RPC\Assertions([
            new Assert\NotBlank(),
            new Assert\Length(min: 3),
        ])]
        string $firstName,
        #[RPC\Assertions([
            new Assert\NotBlank(),
            new Assert\Length(min: 3),
        ])]
        string $lastName,
    ): string
    {
        // create user
    }

    #[Route('/{userId}', name: 'update', methods: ['PUT'])]
    public function update(
        #[RPC\Assertions([
            new Assert\NotBlank(),
            new Assert\Uuid(),
        ])]
        string $userId,
        #[RPC\Assertions([
            new Assert\NotBlank(),
            new Assert\Length(min: 3),
        ])]
        string $firstName,
        #[RPC\Assertions([
            new Assert\NotBlank(),
            new Assert\Length(min: 3),
        ])]
        string $lastName,
    ): string
    {
        // update user
    }
}

🔐 Public API

To expose methods in the public REST layer, the standard JsonRpcBundle access configuration is used, therefore the access control fully mirrors the RPC layer.

🦠 License

MIT © UFO-Tech

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固