PHPackages                             webiik/middleware - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. webiik/middleware

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

webiik/middleware
=================

The Middleware is middleware launcher that allows automatic constructor DI and sending custom data among middleware.

1.0(7y ago)0641MITPHPPHP &gt;=7.2

Since Mar 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/webiik/middleware)[ Packagist](https://packagist.org/packages/webiik/middleware)[ Docs](https://www.webiik.com)[ RSS](/packages/webiik-middleware/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (2)Used By (1)

[![](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)](https://camo.githubusercontent.com/a397347ee4fb199934fee6354504f4702b89f5c22f0ce0ba94c5ff691cde545c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77656269696b2f77656269696b2e737667)[![](https://camo.githubusercontent.com/9063c8611554aba946080355a077ff49c13af18ec286c9e8cd99c8aea668207c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d322d627269676874677265656e2e737667)](https://camo.githubusercontent.com/9063c8611554aba946080355a077ff49c13af18ec286c9e8cd99c8aea668207c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646570656e64656e636965732d322d627269676874677265656e2e737667)

Middleware
==========

[](#middleware)

The Middleware is middleware launcher that allows automatic constructor DI and sending custom data among middleware.

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

[](#installation)

```
composer require webiik/middleware
```

Example
-------

[](#example)

```
$middleware = new \Webiik\Middleware\Middleware($container, $data);
$middleware->add('MwTest:run', ['foo' => 'bar']);
$middleware->run();
```

Writing Middleware
------------------

[](#writing-middleware)

Every middleware has to be a class with at least one public method with the following parameters **[\\Webiik\\Data\\Data $data](../Data/README.md), callable $next**. Every class can contain more methods with the mentioned parameters.

```
class MwTest
{
    public function run(\Webiik\Data\Data $data, callable $next)
    {
        // Get middleware data
        $mwData = $data->getAll(); // Array([foo] => [bar])

        // Change middleware data
        $data->set('foo', 'foo');

        // Launch next middleware
        $next();

        // Continue current middlware...
    }
}
```

You can also use **constructor DI** to inject services from container to middleware. [Read more about DI and container](../Container/README.md).

Adding
------

[](#adding)

### add

[](#add)

```
add(string $controller, $data = []): void
```

**add()** ads middleware to queue.

**Parameters:**

- **controller** string representation of controller and method to be initiated e.g. controllerName:methodName
- **data** a key-value array of data to be injected during the middleware initiation

```
$middleware->add('MwTest:run');
```

Launch
------

[](#launch)

### run

[](#run)

```
run(): void
```

**run()** runs all middleware in queue.

```
$middleware->run();
```

Resources
---------

[](#resources)

- [Webiik framework](https://github.com/webiik/webiik)
- [Report issue](https://github.com/webiik/components/issues)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

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

2599d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1226362d003d186b45e7dfa44489c36af37196c6a1b476206700eaf4e9c96a5a?d=identicon)[Jiri Mihal](/maintainers/Jiri%20Mihal)

---

Top Contributors

[![Jiri-Mihal](https://avatars.githubusercontent.com/u/10408123?v=4)](https://github.com/Jiri-Mihal "Jiri-Mihal (240 commits)")

---

Tags

middleware

### Embed Badge

![Health badge](/badges/webiik-middleware/health.svg)

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

###  Alternatives

[league/uri-components

URI components manipulation library

31932.3M66](/packages/league-uri-components)[bryanjhv/slim-session

Session middleware and helper for Slim framework 4.

233961.5k15](/packages/bryanjhv-slim-session)[timacdonald/has-parameters

A trait that allows you to pass arguments to Laravel middleware in a more PHP'ish way.

228271.7k2](/packages/timacdonald-has-parameters)[reinink/remember-query-strings

Laravel middleware that automatically remembers and restores query strings.

76598.2k3](/packages/reinink-remember-query-strings)[yemenifree/laravel-arabic-numbers-middleware

auto transforms arabic/eastern to eastern/arabic numbers for i.e ١٢٣٤٥٦٧٨ to 12345678

18135.4k](/packages/yemenifree-laravel-arabic-numbers-middleware)[aldemeery/onion

A layering mechanism for PHP applications.

5810.7k2](/packages/aldemeery-onion)

PHPackages © 2026

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