PHPackages                             tbht/press - 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. tbht/press

ActiveLibrary[Framework](/categories/framework)

tbht/press
==========

a frame like nodejs/koa

v0.3.0(5y ago)53Apache-2.0PHPPHP ^7.4CI failing

Since Mar 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/TbhT/press)[ Packagist](https://packagist.org/packages/tbht/press)[ RSS](/packages/tbht-press/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (9)Versions (21)Used By (0)

Press
=====

[](#press)

[![PHP Composer](https://github.com/TbhT/press/workflows/PHP%20Composer/badge.svg)](https://github.com/TbhT/press/workflows/PHP%20Composer/badge.svg)[![codecov](https://camo.githubusercontent.com/82b564bfce4693288761accc6966a5b57a01a9273cdfdf43ccd876cb39ae92d1/68747470733a2f2f636f6465636f762e696f2f67682f546268542f70726573732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/TbhT/press)

> This project is a translation of koa framework of nodejs.

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

[](#installation)

`$ composer require tbht/press`

Hello `Press`
-------------

[](#hello-press)

```
use Press\Application;
use Press\Context;

$app = new Application();

$app->use(function (Context $ctx, callable $next) {
    $ctx->body = 'Hello Press';
});

$app->listen();
```

Middleware
----------

[](#middleware)

Here is an example of logger middleware :

```
use Press\Context;
use Press\Application;

$app = new Application();

$app->use(function (Context $ctx, callable $next) {
    $start = time();
    return $next()
        ->then(function () use($start, $ctx) {
            $ms = time() - $start;
            $method = $ctx->method;
            $url = $ctx->url;

            print_r("{$method} {$url} - {$ms}ms");
        });
});
```

Document
--------

[](#document)

### Application

[](#application)

#### hello world

[](#hello-world)

```
use Press\Application;
use Press\Context;

$app = new Application();

$app->use(function (Context $ctx, callable $next) {
      $ctx->body = 'Hello World';
});

$app->listen(function () {
    var_dump('final var dump');
});

// or

$app->listen(['port' => 8080]);
```

#### Cascading

[](#cascading)

```
use Press\Application;
use Press\Context;

$app = new Application();

// logger
$app->use(function (Context $ctx, callable $next) {
    return $next()
        ->then(function () use ($ctx) {
            $rt = $ctx->response->get('x-response-time');
            $method = $ctx->method;
            $url = $ctx->url;
            echo "{$method} {$url} - {$rt}";
        });
});

// x-response-time
$app->use(function (Context $ctx, callable $next) {
    $start = time();
    return $next()
        ->then(function () use ($ctx,$start) {
            $ms = time() - $start;
            $ctx->set('x-response-time', "{$ms}ms");
        });
});

// response
$app->use(function (Context $ctx, callable $next) {
    $ctx->body = 'Hello World';
});
```

#### Settings

[](#settings)

- `$app->env` default to the 'development'
- `$app->proxy` when true proxy header fields will be trusted
- `$app->subdomainOffset` offset of `.subdomains` to ignore \[2\]

#### $app-&gt;listen(...)

[](#app-listen)

```
use Press\Application;

$app = new Application();

$app->listen([
    "host" => "127.0.0.1",
    "port" => 8080
]);

// or

$app->listen(function () {
    echo "call back run";
});
```

#### $app-&gt;callback()

[](#app-callback)

return a callback function suitable for the following http server request.

```
use React\EventLoop\Factory;

$loop = Factory::create();

$server = new React\Http\Server($loop, function (Psr\Http\Message\ServerRequestInterface $request) {

    // ...

});
```

### $app-&gt;use()

[](#app-use)

see `Middlware` part

### $app-&gt;context

[](#app-context)

`$app->context` is the prototype from which `ctx` is created.

```
$app->use(function ($ctx) {

$ctx->db = new DB();

});
```

### Error handling

[](#error-handling)

```
$app->on("error", function () {

    echo "this is an error";
});
```

Context
-------

[](#context)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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 ~57 days

Total

14

Last Release

1921d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10486739?v=4)[TbhT](/maintainers/TbhT)[@TbhT](https://github.com/TbhT)

---

Top Contributors

[![TbhT](https://avatars.githubusercontent.com/u/10486739?v=4)](https://github.com/TbhT "TbhT (298 commits)")

---

Tags

callbackmiddlewarephpphp7reactphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

43.2k341.0k1](/packages/ccxt-ccxt)[laravel/reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

1.6k15.1M84](/packages/laravel-reverb)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k420.9k26](/packages/team-reflex-discord-php)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k16.4k79](/packages/elgg-elgg)[clue/docker-react

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.

113163.3k1](/packages/clue-docker-react)

PHPackages © 2026

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