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

ActiveLibrary

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

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

v0.3.7(1y ago)01.9k↓100%proprietaryPHPPHP &gt;=8.1.0

Since Mar 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Zrnik/zweist)[ Packagist](https://packagist.org/packages/zrnik/zweist)[ RSS](/packages/zrnik-zweist/feed)WikiDiscussions master Synced 1mo 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

29

—

LowBetter than 60% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

699d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ef2b2321754ec75f086e19c9d2ad58a349217a4fe0a2b8944299173081167dd?d=identicon)[zrnik](/maintainers/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

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M232](/packages/nelmio-api-doc-bundle)[nette/php-generator

🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.5 features.

2.2k64.2M575](/packages/nette-php-generator)[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k114.3M154](/packages/sentry-sentry-laravel)[bref/bref

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k9.6M55](/packages/bref-bref)

PHPackages © 2026

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