PHPackages                             dispatcher/open-api - 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. [Framework](/categories/framework)
4. /
5. dispatcher/open-api

ActiveLibrary[Framework](/categories/framework)

dispatcher/open-api
===================

Data driven dispatcher that implements the OpenApi specification

1.0.0(8y ago)4831[1 issues](https://github.com/virgiliolino/open-api/issues)LGPL-3.0-or-laterPHPPHP &gt;=7.0

Since Apr 30Pushed 8y ago1 watchersCompare

[ Source](https://github.com/virgiliolino/open-api)[ Packagist](https://packagist.org/packages/dispatcher/open-api)[ Docs](https://github.com/virgiliolino/open-api)[ RSS](/packages/dispatcher-open-api/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

Open-api
========

[](#open-api)

Maybe it's about automation, or just about being more declarative because a non Touring complete DSL will just more be correct, I find it just amazing the possibility to describe an API by using the [Open-API-Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/README.md) and let this specification be your code: this class will set every route using the Slim functionalities, and for every route point to a CommandHandler.

I'd suggest, the best way to see it in action is just to clone the repository and try the Example Hello World Application:

```
git clone git@github.com:virgiliolino/open-api.git
cd open-api/Examples/HelloWorld/
composer install   #composer install will actually install Slim and open-api
php -S localhost:8080 -t public #start the server
curl localhost:8080/hello/world # or just open the browser localhost:8080/hello/world

```

For a fully working application, you could take a look at a ReactJS + Slim Skeleton that provides all the functionalities needed for a modern application. The url is [here](https://github.com/incubactor/slim-react-skeleton/)The OpenApi specification is [here](https://app.swaggerhub.com/apis/virgiliolino/slim-react-skeleton/1.0.0)

You will not have a few overpopulated Controllers, but instead for every entry point a command handler. You can read at this [blog post](https://jenssegers.com/85/goodbye-controllers-hello-request-handlers?utm_campaign=Revue%20newsletter&utm_medium=Newsletter&utm_source=A%20Semana%20PHP) for some ideas of how we intend our architecutre

Furthermore, the Open-Api specification can be automatically validated, tested [![Swagger](https://camo.githubusercontent.com/75a91bc738cb7a6c2536ed382fee9f5664f2380f6596c956defe31b3208b3b32/68747470733a2f2f323433347a6432396d697364336534613466316537336b692d7770656e67696e652e6e6574646e612d73736c2e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031362f31312f5377616767657248505f44657369676e2d2e706e67)](https://camo.githubusercontent.com/75a91bc738cb7a6c2536ed382fee9f5664f2380f6596c956defe31b3208b3b32/68747470733a2f2f323433347a6432396d697364336534613466316537336b692d7770656e67696e652e6e6574646e612d73736c2e636f6d2f77702d636f6e74656e742f75706c6f6164732f323031362f31312f5377616767657248505f44657369676e2d2e706e67)

In the end you'll have a yml or json file that describe your API, something like this: [![Json Specification](https://raw.githubusercontent.com/virgiliolino/SwaggerSlimDispatcher/master/swagger.png)](https://raw.githubusercontent.com/virgiliolino/SwaggerSlimDispatcher/master/swagger.png)

By using our library all routes will automatically be set. Every route pointing to a CommandHandler indicated by a unique operationId. So in the image of the example, you can see that there is a route: /pet that accept post requests. It will be enough to use our class, when you start the application the route /pet will accept a post. And so for the gets that you see below, like /pet/findByStatus, etc. For every path, it will be executed the command handler with the operationI. In the example for /pet, you can see the **operationId: addPet**. So making a post request to /pet, the system will try to execute the class AddPet::execute passing the params. The operationId must be a fully qualified name of a class. Something like this for example: operationId: \\MyApplication\\CommandHandlers\\AddPett which means that will execue AddPett::execute

You may find an example of a fully working Open-Api specification [here](http://petstore.swagger.io/) [the full json file](http://petstore.swagger.io/v2/swagger.json)

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

[](#installation)

```
composer require dispatcher/open-api

```

Examples/Helloworld
-------------------

[](#exampleshelloworld)

```
require 'vendor/autoload.php';
$app = new \Slim\App;
$container = $app->getContainer();
//your command Handlers need to be injected by operationId
$container['HelloWorld'] = function () {
    return new \HelloWorld\CommandHandlers\HelloWorld();
};
$openApiFile = 'routes.json';
$openApiConfigParser = Dispatcher\OpenApi\ParserFactory::parserFor($openApiFile);
$openApiConfig = $openApiConfigParser->parse($openApiFile);
$applicationBridge = new \Sab\Application\Bridge\SlimBridge($app);
$routesInjector = new \Dispatcher\OpenApi\Route\DefaultRouteInjector();
$openApiDispatcher = new \Dispatcher\OpenApi\OpenApiDispatcher($routesInjector);
$openApiDispatcher->InjectRoutesFromConfig($applicationBridge, $openApiConfig);

$app->run();

```

As you may see we're injecting HelloWorld, a command Handler with the same id of operationId that you may find on routes.json

That's all folks.

Help wanted
-----------

[](#help-wanted)

There is no validation at all. This process can be automatized. Class *CommandHandler* on the file called *SwaggerDispatcher*.

Thanks, Virgilio

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2982d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/724429?v=4)[Virgilio Lino](/maintainers/virgiliolino)[@virgiliolino](https://github.com/virgiliolino)

---

Top Contributors

[![virgiliolino](https://avatars.githubusercontent.com/u/724429?v=4)](https://github.com/virgiliolino "virgiliolino (26 commits)")[![dragosprotung](https://avatars.githubusercontent.com/u/1081073?v=4)](https://github.com/dragosprotung "dragosprotung (1 commits)")

---

Tags

frameworkswaggeropenapislimbuilderroutedispatcher

### Embed Badge

![Health badge](/badges/dispatcher-open-api/health.svg)

```
[![Health](https://phpackages.com/badges/dispatcher-open-api/health.svg)](https://phpackages.com/packages/dispatcher-open-api)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[slim/slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs

12.3k51.8M1.4k](/packages/slim-slim)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[silverstripe/framework

The SilverStripe framework

7223.7M2.7k](/packages/silverstripe-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
