PHPackages                             oihana/php-controllers - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. oihana/php-controllers

ActiveLibrary[HTTP &amp; Networking](/categories/http)

oihana/php-controllers
======================

The Oihana PHP Controllers library

1.0.0(1mo ago)0371↓11.9%3MPL-2.0PHP &gt;=8.4

Since Jun 21Compare

[ Source](https://github.com/BcommeBois/oihana-php-controllers)[ Packagist](https://packagist.org/packages/oihana/php-controllers)[ Docs](https://github.com/BcommeBois/oihana-php-controllers)[ RSS](/packages/oihana-php-controllers/feed)WikiDiscussions Synced 2w ago

READMEChangelogDependencies (24)Versions (2)Used By (3)

Oihana PHP - Controllers
========================

[](#oihana-php---controllers)

[![Oihana PHP Controllers](https://raw.githubusercontent.com/BcommeBois/oihana-php-controllers/main/assets/images/oihana-php-controllers-logo-inline-512x160.png)](https://raw.githubusercontent.com/BcommeBois/oihana-php-controllers/main/assets/images/oihana-php-controllers-logo-inline-512x160.png)

Composable HTTP controller building blocks for PHP 8.4+, built on [Slim](https://www.slimframework.com/) and [Twig](https://twig.symfony.com/).

[![Latest Version](https://camo.githubusercontent.com/6fe6f069201b6a8d333bede573783e3debe0dfbf477428ae8035b4c0db68e7bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6968616e612f7068702d636f6e74726f6c6c6572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-controllers)
[![Total Downloads](https://camo.githubusercontent.com/f8c81a22ce0794d1e0352465ca0b1ad9dc7d3f6e452f0495c039e8923b709ee3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6968616e612f7068702d636f6e74726f6c6c6572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oihana/php-controllers)
[![License](https://camo.githubusercontent.com/c339049c82a5ff5663bce70334dabec7e7083b9a33e5a4b3a67cebc18aa6df52/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f6968616e612f7068702d636f6e74726f6c6c6572732e7376673f7374796c653d666c61742d737175617265)](LICENSE)

📚 Documentation
---------------

[](#-documentation)

User guides (FR + EN), with narrative explanations and examples:

🇬🇧 **[English documentation](wiki/en/README.md)**🇫🇷 **[Documentation française](wiki/fr/README.md)**Getting started, controller, params, pagination, file responses, archives &amp; upload, Twig, helpers, testing.Démarrage, contrôleur, params, pagination, réponses fichier, archives &amp; upload, Twig, helpers, tests.Auto-generated API reference (phpDocumentor):
👉

🧠 What is it?
-------------

[](#-what-is-it)

`oihana/php-controllers` provides a composable `Controller` base class and a set of focused traits and helpers for building HTTP controllers on top of Slim and Twig: typed request-parameter extraction, pagination, language negotiation, file responses (download, streaming, HTTP range, ETag / 304), archives, uploads, encryption, CSRF, HTTP caching and JSON/CBOR serialization.

```
use DI\Container;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

use oihana\controllers\Controller;

use function oihana\controllers\helpers\getParamInt;

class HelloController extends Controller
{
    public function index( ServerRequestInterface $request, ResponseInterface $response, array $args ): ResponseInterface
    {
        $page = getParamInt( $request, 'page', 1 );
        return $this->json( $response, [ 'page' => $page ] );
    }
}
```

🚀 Features
----------

[](#-features)

- 🎛️ A composable `Controller` base and focused traits — params, pagination, languages, routing, status, Twig, JSON/CBOR.
- 🧩 Typed request-parameter extraction &amp; strategies — `ParamsTrait`, `ParamsStrategyTrait`, the `getParam*()` helpers.
- 📥 File responses — download, streaming, HTTP range, ETag &amp; 304 Not Modified, content headers.
- 🗜️ Archives, uploads &amp; encryption — zip/tar, file upload and OpenSSL file encryption.
- 🛡️ CSRF, HTTP cache and language negotiation on top of Slim &amp; Twig.
- 🖼️ Image responses &amp; resizing via `ext-imagick`.
- 🧪 Full unit-test coverage ensuring reliability and maintainability.

💡 Designed to be composable, testable, and compatible with any PHP 8.4+ project.

📦 Installation
--------------

[](#-installation)

> **Requires [PHP 8.4+](https://php.net/releases/)** and the **`ext-imagick`** extension.

Install via [Composer](https://getcomposer.org):

```
composer require oihana/php-controllers
```

✅ Tests &amp; coverage
----------------------

[](#-tests--coverage)

Run the full unit-test suite (PHPUnit, strict mode):

```
composer test
```

Run a single test case:

```
./vendor/bin/phpunit --filter PaginationTraitTest
```

Measure coverage (requires Xdebug or PCOV):

```
composer coverage        # text + Clover + HTML under build/coverage/
composer coverage:md     # readable Markdown summary (build/coverage/COVERAGE.md)
```

The suite runs in **strict mode** and targets **100% line coverage**.

🧾 License
---------

[](#-license)

This project is licensed under the [Mozilla Public License 2.0 (MPL-2.0)](https://www.mozilla.org/en-US/MPL/2.0/).

👤 About the author
------------------

[](#-about-the-author)

- Author : Marc ALCARAZ (aka eKameleon)
- Mail :
- Website :

🛠️ Generate the Documentation
-----------------------------

[](#️-generate-the-documentation)

We use [phpDocumentor](https://phpdoc.org/) to generate the documentation into the ./docs folder.

### Usage

[](#usage)

Run the command :

```
composer doc
```

🔗 Related packages
------------------

[](#-related-packages)

- [oihana/php-models](https://github.com/BcommeBois/oihana-php-models) – document/PDO models used by the data controllers.
- [oihana/php-files](https://github.com/BcommeBois/oihana-php-files) – file, archive and encryption helpers behind the file responses.
- [oihana/php-core](https://github.com/BcommeBois/oihana-php-core) – core helpers and utilities used by this library.
- [oihana/php-enums](https://github.com/BcommeBois/oihana-php-enums) – strongly-typed constant enumerations for PHP.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance90

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d234506e51778dd3d1d61b6c2af6f294ff963651b4aa509b595d3d2a77b7d89b?d=identicon)[ooop](/maintainers/ooop)

---

Tags

httppsr-7phpresttwigslimcontrollers

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/oihana-php-controllers/health.svg)

```
[![Health](https://phpackages.com/badges/oihana-php-controllers/health.svg)](https://phpackages.com/packages/oihana-php-controllers)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.4M2.2k](/packages/symfony-symfony)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k39.6k](/packages/matomo-matomo)[cakephp/cakephp

The CakePHP framework

8.9k20.0M1.8k](/packages/cakephp-cakephp)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k19](/packages/tempest-framework)[getgrav/grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS

15.6k88.1k1](/packages/getgrav-grav)[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)

PHPackages © 2026

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