radebatz/openapi-router 问题修复 & 功能扩展

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

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

radebatz/openapi-router

最新稳定版本:3.1.0

Composer 安装命令:

composer require radebatz/openapi-router

包简介

Routing adapter for OpenApi annotations.

README 文档

README

Build Status Coverage Status License: MIT

Introduction

Allows to (re-)use Swagger-PHP attributes (docblock annotations are deprecated), to configure routes in the following frameworks:

Requirements

Installation

You can use composer or simply download the release.

Composer

The preferred method is via composer. Follow the installation instructions if you do not already have composer installed.

Once composer is installed, execute the following command in your project root to install this library:

composer require radebatz/openapi-router

After that all required classes should be availabe in your project to add routing support.

Basic usage

Example using the Slim framework adapter and standard OpenApi attributes only.

Controller

<?php namespace MyApp\Controllers\V1; use OpenApi\Attributes as OA; use Radebatz\OpenApi\Extras\Attributes as OAX; /* Things shared by all endpoints in this controller.*/ #[OAX\Controller(prefix: '/api/v1')] #[OA\Response(response: 200, description: 'OK')] #[OAX\Middleware(names: ['auth', 'admin'])] class GetController { #[OA\Get(path: '/getme', operationId: 'getme')] #[OA\Response(response: 400, description: 'Not good enough')] public function getme($request, $response) { return $response->write('Get me'); } }

index.php

<?php use Radebatz\OpenApi\Routing\Adapters\SlimRoutingAdapter; use Radebatz\OpenApi\Routing\OpenApiRouter; use Slim\App; require '../vendor/autoload.php'; $app = new App(); (new OpenApiRouter([__DIR__ . '/../src/controllers'], new SlimRoutingAdapter($app))) ->registerRoutes(); $app->run();

Documentation

License

The openapi-router project is released under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

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