PHPackages                             ilariopro/zenigata - 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. ilariopro/zenigata

ActiveLibrary[Framework](/categories/framework)

ilariopro/zenigata
==================

0.1.0(2w ago)00MITPHPPHP ^8.2 || ^8.3 || ^8.4CI passing

Since May 22Pushed 2w agoCompare

[ Source](https://github.com/ilariopro/zenigata)[ Packagist](https://packagist.org/packages/ilariopro/zenigata)[ RSS](/packages/ilariopro-zenigata/feed)WikiDiscussions main Synced 1w ago

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

Zenigata
========

[](#zenigata)

> ⚠️ This project is in an early development stage. Feedback and contributions are welcome!

A lightweight, PSR-compliant HTTP framework for PHP 8.2+ built for flexibility and simplicity.

Built around standard interfaces and a composable architecture, it gives you full control over routing, middleware, and error responses — powered by [League Route](https://route.thephpleague.com/) under the hood, with sensible defaults that work out of the box.

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

[](#requirements)

- PHP &gt;= 8.2
- A [PSR-7](https://www.php-fig.org/psr/psr-7/) and [PSR-17](https://www.php-fig.org/psr/psr-17/) implementation such as:
    - [`nyholm/psr7`](https://github.com/Nyholm/psr7)
    - [`guzzlehttp/psr7`](https://github.com/guzzle/psr7)
    - [`laminas/laminas-diactoros`](https://github.com/laminas/laminas-diactoros)
    - [`slim/psr7`](https://github.com/slimphp/Slim-Psr7)
- [Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos)

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

[](#installation)

```
composer require ilariopro/zenigata
```

Overview
--------

[](#overview)

### Application

[](#application)

[`Application`](src/Application.php) is the main entry point of the framework. It orchestrates the **full HTTP request lifecycle** and provides a **centralized API** to interact with all internal components: registering routes and middleware, setting the dispatch strategy, propagating shared state such as a PSR-11 container or debug mode, and running or emitting responses.

`Application` implements `RouteCollectionInterface` and `StrategyAwareInterface` from League Route, so all routing methods are available directly on the instance.

### Routing &amp; Middleware

[](#routing--middleware)

Routing and middleware dispatching are powered by [League Route](https://route.thephpleague.com/). Incoming requests are matched to registered routes and processed through the middleware stack before the handler is invoked. Middleware can be applied globally or scoped to individual routes and groups.

[`BodyParserMiddleware`](src/Middleware/BodyParserMiddleware.php) parses the incoming request body based on the `Content-Type` header and attaches the parsed data to the request. Ships with built-in parsers for **JSON**, **XML**, and **URL-encoded** bodies, all replaceable or extendable.

### Strategies

[](#strategies)

League Route's [strategy system](https://route.thephpleague.com/unstable/strategies/) controls how route handlers are invoked and how their return values are converted into PSR-7 responses. `ApplicationStrategy` is used by default, meaning handlers must return a `ResponseInterface`. Other strategies such as `JsonStrategy` allow returning plain arrays or other values that are automatically converted.

### Error

[](#error)

[`ErrorHandler`](src/Error/ErrorHandler.php) catches any `Throwable` thrown during the request lifecycle and converts it into a PSR-7 error response via an **error processor** selected by the `Accept` header. Supports an optional **PSR-3 logger** and debug mode for full exception details. Ships with strategies for **HTML** (used by default), **JSON**, **XML**, and **plain text**.

### Runtime

[](#runtime)

- [`RequestInitializer`](src/Request/RequestInitializer.php) builds a PSR-7 `ServerRequestInterface` from PHP superglobals using [Nyholm PSR-7 Server](https://github.com/Nyholm/psr7-server), normalizing headers, uploaded files, and body content. PSR-17 factories are auto-discovered via [php-http/discovery](https://github.com/php-http/discovery) if not explicitly provided.
- [`ResponseEmitter`](src/Response/ResponseEmitter.php) sends the final PSR-7 response to the client, automatically switching to chunked streaming for file downloads and range responses to minimize memory usage.

Usage
-----

[](#usage)

### Minimal Setup

[](#minimal-setup)

```
use Laminas\Diactoros\Response\TextResponse;
use Zenigata\Http\Application;

$app = new Application();

$app->get('/hello', function (ServerRequestInterface $request): ResponseInterface {
    return new TextResponse('Hello, world!');
});

$app->run();
```

### Routes

[](#routes)

```
$app->get('/users', [UserController::class, 'index']);
$app->post('/users', [UserController::class, 'create']);
$app->put('/users/{id}', [UserController::class, 'update']);
$app->delete('/users/{id}', [UserController::class, 'delete']);

// Multiple methods on the same path
$app->map(['GET', 'POST'], '/contact', ContactController::class);

// Route groups with a shared prefix
$app->group('/api', function ($router) {
    $router->get('/users', [UserController::class, 'index']);
    $router->post('/users', [UserController::class, 'create']);
});
```

### Handlers

[](#handlers)

Handlers can be defined in several ways:

```
// Closure
$app->get('/hello', function (ServerRequestInterface $request): ResponseInterface { ... });

// Invokable class
$app->get('/hello', InvokableHandler::class);

// [Class, method] pair
$app->get('/users', [UserController::class, 'index']);

// PSR-15 RequestHandlerInterface
$app->get('/users', Psr15Handler::class);
```

When defined as strings or `[Class, method]` pairs, handlers are resolved from the container if one is configured, or instantiated automatically if the class has no mandatory constructor parameters.

### Middleware

[](#middleware)

```
use Zenigata\Http\Middleware\BodyParserMiddleware;

// Global middleware — applied to every request, in registration order
$app->middleware(new BodyParserMiddleware());
$app->middleware(AuthMiddleware::class); // resolved from container

// Multiple at once
$app->middlewares([
    new BodyParserMiddleware(),
    AuthMiddleware::class,
]);

// Route-level middleware
$app->get('/admin', AdminController::class)
    ->middleware(new AuthMiddleware());

// Group-level middleware
$app->group('/admin', function ($router) {
    $router->get('/dashboard', [AdminController::class, 'dashboard']);
})->middleware(new AuthMiddleware());
```

### Strategies

[](#strategies-1)

The default `ApplicationStrategy` expects handlers to return a `ResponseInterface`. Switch to `JsonStrategy` to return plain arrays or objects that are automatically encoded:

```
use League\Route\Strategy\JsonStrategy;

$strategy = new JsonStrategy(new ResponseFactory());
$app->setStrategy($strategy);

$app->get('/users', function (): array {
    return [
        'id'   => 1,
        'name' => 'Alice'
    ];
});
```

Strategies can also be set per route or per group:

```
$app->get('/users', [UserController::class, 'index'])
    ->setStrategy(new JsonStrategy(new ResponseFactory()));
```

### Error Handling

[](#error-handling)

Any uncaught exception is passed to `ErrorHandler`, which selects the right strategy based on the `Accept` header. In debug mode, responses include the full exception details:

```
$app->setDebug(true);
```

Attach a PSR-3 logger to record errors alongside request context:

```
$app->setLogger($logger);
```

### Container Integration

[](#container-integration)

Pass any PSR-11 container to resolve middleware, handlers, and error processors by service ID:

```
$app->setContainer($container);

$app->middleware('app.middleware.auth');
$app->get('/users', 'app.handler.users');
```

The container is automatically propagated to the active strategy and error handler.

Extensibility
-------------

[](#extensibility)

**Zenigata** is designed for flexibility. Every internal component can be replaced by passing a custom implementation to the constructor:

```
$app = new Application(
    router:             new Router(),
    errorHandler:       new MyErrorHandler(),
    requestInitializer: new MyRequestInitializer(),
    responseEmitter:    new MyResponseEmitter(),
);
```

Custom error processors can be registered at any time:

```
$app->errorProcessor(new SentryErrorProcessor());
$app->errorProcessor(MyCustomProcessor::class);
```

You can also extend `Application` directly and override any `protected` method to customize specific behaviors without replacing entire components.

Contributing
------------

[](#contributing)

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

Keep the implementation minimal, focused, and well-documented, making sure to update tests accordingly.

See [CONTRIBUTING](CONTRIBUTING.md) for more information.

License
-------

[](#license)

This library is licensed under the MIT license. See [LICENSE](LICENSE) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance96

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

18d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/28644849?v=4)[Ilario Promutico](/maintainers/ilariopro)[@ilariopro](https://github.com/ilariopro)

---

Top Contributors

[![ilariopro](https://avatars.githubusercontent.com/u/28644849?v=4)](https://github.com/ilariopro "ilariopro (16 commits)")

---

Tags

http-frameworkphppsr-11psr-15psr-3psr-7

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ilariopro-zenigata/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

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

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[symfony/symfony

The Symfony PHP framework

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

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M395](/packages/drupal-core-recommended)[spiral/framework

Spiral, High-Performance PHP/Go Framework

2.0k2.1M63](/packages/spiral-framework)

PHPackages © 2026

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