PHPackages                             dispatcher/swagger-dispatcher - 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. [API Development](/categories/api)
4. /
5. dispatcher/swagger-dispatcher

ActiveLibrary[API Development](/categories/api)

dispatcher/swagger-dispatcher
=============================

Swagger Dispatcher

3441[2 issues](https://github.com/virgiliolino/SwaggerSlimDispatcher/issues)PHP

Since Apr 30Pushed 8y ago2 watchersCompare

[ Source](https://github.com/virgiliolino/SwaggerSlimDispatcher)[ Packagist](https://packagist.org/packages/dispatcher/swagger-dispatcher)[ RSS](/packages/dispatcher-swagger-dispatcher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SlimSwaggerDispatcher - DISCONTINUED
====================================

[](#slimswaggerdispatcher---discontinued)

Development continue on
==================================================================

[](#development-continue-on-httpsgithubcomvirgiliolinoopen-api)

Maybe it's about automation, or just about beign more declarative because a DSL non Touring complete language will just more correct, anyway 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/SwaggerSlimDispatcher.git
cd SwaggerSlimDispatcher/Examples/HelloWorld/
composer install   #composer install will actually install Slim and SwaggerSlimDispatcher
php -S localhost:8080 -t public public/index.php #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 Api specification from Swagger 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)

Even if its working, I'd not consider it really a *stable* package. So to install it you need to proceed in that way:

```
 composer require dispatcher/swagger-dispatcher dev-master

```

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

[](#exampleshelloworld)

```
$app = new \Slim\App;
$container = $app->getContainer();
$container['HelloWorld'] = function ($c) {
    return new \HelloWorld\CommandHandlers\HelloWorld();
};

$swaggerApiFile = 'routes.json';
$commandHandler = new Dispatcher\Swagger\DefaultCommandRegisterer();
$swaggerConfigParser = Dispatcher\Swagger\ParserFactory::parserFor($swaggerFile);
$swaggerConfig = $swaggerConfigParser->parse($swaggerFile);
\Dispatcher\Swagger\SwaggerDispatcher::InjectRoutesFromConfig($app, $swaggerConfig);

```

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

19

—

LowBetter than 10% of packages

Maintenance7

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/750c7c313126d196e7b4670725a573a9b3d2976785f858fa7eac4ac83776b1af?d=identicon)[virgiliolino](/maintainers/virgiliolino)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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