PHPackages                             membrane/openapi-router - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. membrane/openapi-router

ActiveLibrary

membrane/openapi-router
=======================

0.5.2(1y ago)221.9k↓17.6%2[2 issues](https://github.com/membrane-php/openapi-router/issues)3MPL-2.0PHPPHP ^8.1.0CI passing

Since Feb 17Pushed 1y ago2 watchersCompare

[ Source](https://github.com/membrane-php/openapi-router)[ Packagist](https://packagist.org/packages/membrane/openapi-router)[ RSS](/packages/membrane-openapi-router/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (10)Versions (14)Used By (3)

OpenAPI Router
==============

[](#openapi-router)

This library routes HTTP requests to operationIds in your OpenAPI specification. To make sure it runs quickly we've used techniques inspired by [Nikita Popov](https://www.npopov.com/2014/02/18/Fast-request-routing-using-regular-expressions.html)and [Nicolas Grekas](https://nicolas-grekas.medium.com/making-symfonys-router-77-7x-faster-1-2-958e3754f0e1).

Requirements
------------

[](#requirements)

- A valid [OpenAPI specification](https://github.com/OAI/OpenAPI-Specification#readme).
- An operationId on all [Operation Objects](https://spec.openapis.org/oas/v3.1.0#operation-object) so that each route is uniquely identifiable.

Rules
-----

[](#rules)

### Naming Conventions

[](#naming-conventions)

- Forward slashes at the end of a server url will be ignored since [paths MUST begin with a forward slash.](https://spec.openapis.org/oas/v3.1.0#paths-object)
- [Dynamic paths which are identical other than the variable names MUST NOT exist.](https://spec.openapis.org/oas/v3.1.0#paths-object)

### Routing Priorities

[](#routing-priorities)

- [Static urls MUST be prioritized over dynamic urls](https://spec.openapis.org/oas/v3.1.0#paths-object).
- Longer urls are prioritized over shorter urls.
- Hosted servers will be prioritized over hostless servers.

Installation
------------

[](#installation)

```
composer require membrane/openapi-router

```

Quick Start
-----------

[](#quick-start)

To read routes dynamically, you can do the following:

```
