PHPackages                             spacetab-io/amphp-support - 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. spacetab-io/amphp-support

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

spacetab-io/amphp-support
=========================

Package to reduce code duplication across services.

1.1.0(6y ago)23692MITPHPPHP &gt;=7.4

Since Apr 19Pushed 5y ago2 watchersCompare

[ Source](https://github.com/spacetab-io/amphp-support-php)[ Packagist](https://packagist.org/packages/spacetab-io/amphp-support)[ RSS](/packages/spacetab-io-amphp-support/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (9)Versions (5)Used By (0)

Amphp support
=============

[](#amphp-support)

[![CircleCI](https://camo.githubusercontent.com/4c0ce949e24e0ee733d35869ac72df0fa87e88d1ad47f107e2e2fe627b437fdf/68747470733a2f2f636972636c6563692e636f6d2f67682f73706163657461622d696f2f616d7068702d737570706f72742d7068702f747265652f6d61737465722e7376673f7374796c653d737667)](https://circleci.com/gh/spacetab-io/amphp-support-php/tree/master)[![codecov](https://camo.githubusercontent.com/921c766ab3a14a822a7df6d3606064d8f816f6d2dbfa2a312c3a312a5ed0a6c9/68747470733a2f2f636f6465636f762e696f2f67682f73706163657461622d696f2f616d7068702d737570706f72742d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/spacetab-io/amphp-support-php)

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

[](#installation)

```
composer require spacetab-io/amphp-support
```

Usage
-----

[](#usage)

```
use Amp\Http\{Server\HttpServer, Server\Request, Server\Response, Server\Router, Status};
use Amp\{Loop, Promise, Socket};
use HarmonyIO\Validation\Rule\{Combinator\All, Text\AlphaNumeric, Text\LengthRange};
use Spacetab\AmphpSupport\Handler\AbstractTrustedRequest;
use Spacetab\AmphpSupport\Server\ErrorHandler;
use Spacetab\AmphpSupport\Middleware\{AcceptJsonBody, ExceptionMiddleware};
use function Amp\call;

Loop::run(function () {
    $sockets = [
        Socket\Server::listen('0.0.0.0:8081'),
    ];

    $router = new Router();

    $handler = new class extends AbstractTrustedRequest {
        public function handleRequest(Request $request): Promise {
            var_dump($this->getTrustedBody());
            return call(fn() => new Response(Status::OK, [], '{"message": "hey!"}'));
        }
    };

    $router->stack(new ExceptionMiddleware());
    $router->addRoute('POST', '/', $handler, new class extends AcceptJsonBody {
        public function validate(): iterable {
            yield 'username' => new All(new LengthRange(3, 15), new AlphaNumeric());
        }
    });

    $server = new HttpServer($sockets, $router, new \Psr\Log\NullLogger());
    $server->setErrorHandler(new ErrorHandler());

    yield $server->start();

    // Stop the server gracefully when SIGINT is received.
    Loop::onSignal(SIGINT, function (string $watcherId) use ($server) {
        Loop::cancel($watcherId);
        yield $server->stop();
    });
});
```

```
curl -X POST -d '{"username": "roquie"}' -H 'Content-Type: application/json' http://0.0.0.0:8081/ | jq .
```

Depends
-------

[](#depends)

- &gt;= PHP 7.4
- Composer for install package

License
-------

[](#license)

The MIT License

Copyright © 2020 spacetab.io, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

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

Total

4

Last Release

2198d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35d8eff4a3e66b58f3e2af56fe948035469de1e19ac29c532d65c681955bbd18?d=identicon)[Roquie](/maintainers/Roquie)

---

Top Contributors

[![roquie](https://avatars.githubusercontent.com/u/3214290?v=4)](https://github.com/roquie "roquie (6 commits)")

---

Tags

amphpasyncphpphp74

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spacetab-io-amphp-support/health.svg)

```
[![Health](https://phpackages.com/badges/spacetab-io-amphp-support/health.svg)](https://phpackages.com/packages/spacetab-io-amphp-support)
```

###  Alternatives

[godbout/dash-docset-builder

Dash (LOVE) Docset Builder in PHP (LOVE).

1253.5k](/packages/godbout-dash-docset-builder)

PHPackages © 2026

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