PHPackages                             zrnik/zweist - 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. zrnik/zweist

ActiveLibrary[API Development](/categories/api)

zrnik/zweist
============

OpenAPI routing for Slim Framework 4 with `zircote/swagger-php`

v0.3.7(2y ago)02.1kproprietaryPHPPHP &gt;=8.1.0

Since Mar 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Zrnik/zweist)[ Packagist](https://packagist.org/packages/zrnik/zweist)[ RSS](/packages/zrnik-zweist/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (13)Versions (23)Used By (0)

Zweist
======

[](#zweist)

> "I'm susperd the mountain zweist" - Lenka Dusilová

### What is this?

[](#what-is-this)

This is a routing tool for `Slim Framework 4` to generate router only by using `zircote/swagger-php` attributes (or maybe annotations, didn't test it) to generate the router.

```
composer require zrnik/zweist

```

### What do you mean?

[](#what-do-you-mean)

#### 1. You annotate your controller methods with the `zircote/swagger-php` attributes

[](#1-you-annotate-your-controller-methods-with-the-zircoteswagger-php-attributes)

```
class HelloWorldController
{
    public function __construct(
        private readonly \Zrnik\Zweist\Content\JsonContentFacade $jsonContentFacade,
    ) {}

    /**
     * @param array $arguments
     * @throws JsonException
     */
    #[
        Get(
            path: '/api/hello/{name:.*}',
            operationId: 'Say Hello',
            description: 'says hello by the request parameter',
        ),
        Response(
            response: 200,
            description: 'when ok',
            content: new JsonContent(ref: TestResponse::class)
        ),
        Middleware(ExampleMiddleware::class),
    ]
    public function sayHello(
        RequestInterface $request,
        ResponseInterface $response,
        array $arguments = []
    ): ResponseInterface
    {
        return $this->jsonContentFacade->updateResponse(
            $response,
            new TestResponse(
                sprintf(
                    'Hello, %s :)',
                    $arguments['name']
                )
            )
        );
    }
}
```

#### 2. Add `ZweistConfiguration` to your DI.

[](#2-add-zweistconfiguration-to-your-di)

```
$zweistConfiguration = new ZweistConfiguration(

    // scan paths for openapi attributes (requests & schemas)
    [
        __DIR__ . '/../../Controllers',
        __DIR__ . '/../../Model',
    ],

    // generated (and committed) files
    __DIR__ . '/openapi.json',
    __DIR__ .'/router.json',
);
```

#### 3. Generate (and commit) `openapi.json` &amp; `router.json`

[](#3-generate-and-commit-openapijson--routerjson)

```
$zweistOpenApiGenerator = $container->get(ZweistOpenApiGenerator::class);
$zweistOpenApiGenerator->generate();
```

#### 4. Let `ZweistRouteService` populate routes in the `\Slim\App` instance.

[](#4-let-zweistrouteservice-populate-routes-in-the-slimapp-instance)

```
$zweistRouteService = $container->get(ZweistRouteService::class);
$zweistRouteService->applyRoutes($app);
```

More things you should know
---------------------------

[](#more-things-you-should-know)

You will need to create a class with `openapi`description attributes. (see [./tests/ExampleApplication/ExampleApplicationInfo.php](./tests/ExampleApplication/ExampleApplicationInfo.php))

You want to **generate** `openapi.json` and `router.json` locally when developing, and then committing them with your code, because you do not want to scan all the files for the router at runtime for every request.

You should check on the CI that you didn't forget to generate new files.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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.

###  Release Activity

Cadence

Every ~4 days

Recently: every ~12 days

Total

22

Last Release

746d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/55077930?v=4)[Štěpán Zrník](/maintainers/zrnik)[@Zrnik](https://github.com/Zrnik)

---

Top Contributors

[![Zrnik](https://avatars.githubusercontent.com/u/55077930?v=4)](https://github.com/Zrnik "Zrnik (33 commits)")

---

Tags

openapi3phproutingslim-frameworkslim4swagger-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zrnik-zweist/health.svg)

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

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k36.4M126](/packages/darkaonline-l5-swagger)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M518](/packages/shopware-core)[brandembassy/slim-nette-extension

19198.2k](/packages/brandembassy-slim-nette-extension)[toshy/bunnynet-php

BunnyNet API client for PHP

61195.4k13](/packages/toshy-bunnynet-php)[chartmogul/chartmogul-php

ChartMogul API PHP Client

181.4M](/packages/chartmogul-chartmogul-php)

PHPackages © 2026

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