PHPackages                             wickedbyte/api-handler - 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. wickedbyte/api-handler

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

wickedbyte/api-handler
======================

Simple set of handlers to add an API to any project.

v3.0.0(2d ago)00MITPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Apr 19Pushed 2d agoCompare

[ Source](https://github.com/wickedbyte/api-handler)[ Packagist](https://packagist.org/packages/wickedbyte/api-handler)[ Docs](https://github.com/wickedbyte/api-handler)[ RSS](/packages/wickedbyte-api-handler/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (13)Versions (6)Used By (0)

API Handler
===========

[](#api-handler)

> This project is an independently maintained fork of [phoneburner/api-handler](https://github.com/phoneburner/api-handler), originally released under the MIT license, by the original project authors. This fork is neither affiliated with nor endorsed by PhoneBurner.

Simple set of PSR-15 request handlers to add an API to any project. Provides CRUD operation handlers, response transformation capabilities, and middleware-based request dispatching.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- [`wickedbyte/http-tortilla`](https://github.com/wickedbyte/http-tortilla) ^3.0
- [`psr/http-message`](https://github.com/php-fig/http-message) ^2.0
- [`psr/http-factory`](https://github.com/php-fig/http-factory) ^1.0
- [`psr/http-server-middleware`](https://github.com/php-fig/http-server-middleware) ^1.0

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

[](#installation)

The preferred method of installation is to use [Composer](https://getcomposer.org/):

```
composer require wickedbyte/api-handler
```

Usage
-----

[](#usage)

This library provides a set of CRUD handlers (`CreateHandler`, `ReadHandler`, `UpdateHandler`, `DeleteHandler`) that implement `Psr\Http\Server\RequestHandlerInterface`. Each handler is composed of small, focused interfaces:

- **`Resolver`** — Resolves a domain object from the incoming request (e.g. fetch an entity by ID).
- **`Hydrator`** — Creates, updates, or deletes a domain object based on the request.
- **`Transformer`** — Transforms a domain object into the response body content.
- **`ResponseFactory`** — Builds the PSR-7 response from a `TransformableResource`.

Handlers can be dispatched via the included `DispatchMiddleware`, which uses a `HandlerFactory` to route requests to the appropriate handler:

```
