PHPackages                             curlpit/curlpit - 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. curlpit/curlpit

ActiveLibrary[Framework](/categories/framework)

curlpit/curlpit
===============

A PSR-15 middleware orchestrator for PHP – with branching, looping, and declarative flow control built in

1.0.0(1w ago)02↓100%MITPHPPHP ^8.1CI passing

Since Mar 13Pushed 1w ago1 watchersCompare

[ Source](https://github.com/cURLpit/cURLpit)[ Packagist](https://packagist.org/packages/curlpit/curlpit)[ RSS](/packages/curlpit-curlpit/feed)WikiDiscussions main Synced today

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

[cURLpit](https://github.com/curlpit/curlpit)
=============================================

[](#curlpit)

Curlpit is a PSR-15 middleware orchestrator for PHP – with branching, looping, and declarative flow control built in.

Most middleware stacks are pipelines: request goes in, response comes out, linearly. Curlpit treats the middleware stack as an **instruction sequence** – with a program counter, named labels, conditional jumps, and loops. Business logic that would otherwise be hardcoded in handlers can be expressed as configuration.

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

[](#installation)

```
composer require curlpit/curlpit
```

Then install a PSR-7/17 implementation of your choice:

```
# nyholm/psr7 (recommended – lightweight, zero dependencies)
composer require nyholm/psr7 nyholm/psr7-server

# or guzzlehttp/psr7
composer require guzzlehttp/psr7
```

How it differs
--------------

[](#how-it-differs)

Standard PSR-15CurlpitExecutionLinear chainInstruction sequence (program counter)BranchingNone`JumpMiddleware` (conditional goto)LoopingNone`LoopMiddleware` + `LoopContext`StateInformalExplicit Set/Get/Inc/Dec middlewareError handlingManualBuilt-in `ErrorHandlerMiddleware`ConfigCode onlyJSON-declarableQuick start
-----------

[](#quick-start)

Extend `Application`, override `instantiate()` to wire up your dependencies, point it at a `middleware.json`:

```
use Curlpit\App\Application;
use Curlpit\Core\Emitter;

class MyApp extends Application
{
    protected function instantiate(string $class, array $options): MiddlewareInterface
    {
        return match ($class) {
            MyMiddleware::class => new MyMiddleware($this->responseFactory),
            default             => parent::instantiate($class, $options),
        };
    }
}

$app      = new MyApp($responseFactory, $streamFactory);
$response = $app->handle($serverRequest);
(new Emitter())->emit($response);
```

Flow config (middleware.json)
-----------------------------

[](#flow-config-middlewarejson)

```
{
  "middleware": [
    { "Curlpit\\Core\\Middleware\\ErrorHandlerMiddleware": { "debug": false } },
    { "My\\AuthMiddleware": {} },
    {
      "Curlpit\\Core\\Middleware\\JumpMiddleware": {
        "condition": { "type": "attr", "name": "user_role", "eq": "admin" },
        "jump_to_label": "admin"
      }
    },
    { "My\\PublicDispatch": {} },
    { "My\\AdminDispatch": { "label": "admin" } }
  ]
}
```

Condition DSL
-------------

[](#condition-dsl)

```
{ "type": "always" }
{ "type": "never" }
{ "type": "attr",    "name": "status",   "eq":  "active" }
{ "type": "attr",    "name": "retries",  "lte": 3        }
{ "type": "context", "name": "has_more"                  }
{ "type": "context", "name": "count",    "gt":  0        }
```

Operators: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`. Without an operator, truthy check.

Built-in middleware
-------------------

[](#built-in-middleware)

- **`RequestHandler`** – PSR-15 handler with program counter and label-based jumps
- **`JumpMiddleware`** – conditional branch to a named label
- **`LoopMiddleware`** – repeat a sub-handler while a condition holds
- **`LoopContext`** – mutable state container for loop iterations
- **`RoutingMiddleware`** – path pattern matching with `{param}` placeholders, 404/405 aware
- **`DispatchMiddleware`** – resolves and calls the matched handler via an injected resolver callable
- **`ErrorHandlerMiddleware`** – catches all exceptions, returns JSON or plaintext based on Accept header
- **`SetVariableMiddleware`** / **`GetVariableMiddleware`** – read/write request attributes
- **`IncrementMiddleware`** / **`DecrementMiddleware`** – numeric counters in request attributes
- **`ConfigLoader`** – loads and validates `middleware.json`, standalone and cacheable
- **`Emitter`** – sends PSR-7 responses to the SAPI with chunked streaming

Example project
---------------

[](#example-project)

[DBCommander](https://github.com/curlpit/dbcommander) – a Norton Commander-style MySQL manager built on Curlpit.

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 87% of packages

Maintenance98

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

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

12d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1241020f73e73cefa543459e6858cbb25c36a4a9b5bbb3e446f2f424430a44b7?d=identicon)[cURLpit](/maintainers/cURLpit)

---

Top Contributors

[![cURLpit](https://avatars.githubusercontent.com/u/89288740?v=4)](https://github.com/cURLpit "cURLpit (7 commits)")

---

Tags

phpmiddlewarepsr-15flowpipeline

### Embed Badge

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

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

###  Alternatives

[chubbyphp/chubbyphp-framework

A minimal, highly performant middleware PSR-15 microframework built with as little complexity as possible, aimed primarily at those developers who want to understand all the vendors they use.

13443.8k4](/packages/chubbyphp-chubbyphp-framework)[yiisoft/csrf

Yii CSRF Protection Library

26245.0k7](/packages/yiisoft-csrf)[yiisoft/rate-limiter

Yii Rate Limiter Middleware

2963.3k](/packages/yiisoft-rate-limiter)[yiisoft/session

A session service, PSR-15 session middleware, and a flash message service which helps use one-time messages.

20301.8k10](/packages/yiisoft-session)[igniphp/framework

Swoole, PSR-7, PSR-15 modular micro anti-framework.

2651.0k1](/packages/igniphp-framework)[nimbly/limber

A super minimal HTTP framework that doesn't get in your way.

208.9k](/packages/nimbly-limber)

PHPackages © 2026

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