PHPackages                             mindplay/sapi-host - 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. mindplay/sapi-host

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

mindplay/sapi-host
==================

FCGI SAPI host for dispatch of PSR-15 Handler

1.0.1(1y ago)018MITPHPPHP ^8.1

Since Apr 4Pushed 1y agoCompare

[ Source](https://github.com/mindplay-dk/sapi-host)[ Packagist](https://packagist.org/packages/mindplay/sapi-host)[ RSS](/packages/mindplay-sapi-host/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (8)Versions (22)Used By (0)

`mindplay/sapi-host`
--------------------

[](#mindplaysapi-host)

This library implements a SAPI host for dispatch of PSR-15 `RequestHandlerInterface`.

In a nutshell, this is a front-controller for the `index.php` file in a PSR-7/15/17 based project.

Originally a fork of [Daniel Bannert](https://github.com/prisis)'s [`narrowspark/http-emitter`](https://packagist.org/packages/narrowspark/http-emitter) package, this package takes a different approach, internally leveraging [Tobias Nyholm](https://github.com/Nyholm)'s [`nyholm/psr7-server`](https://packagist.org/packages/nyholm/psr7-server) package to bootstrap the incoming PSR-7 Request.

The philosophy of this package is that hosting a *single* handler, for a *single* request, should be a *single* operation.

Usage
-----

[](#usage)

To bootstrap a `SapiHost`, you need to pick a [PSR-7](https://www.php-fig.org/psr/psr-7/) and [PSR-17](https://www.php-fig.org/psr/psr-17/) implementation - for example, `nyholm/psr7-server`supports both, and you can install it with:

```
composer require nyholm/psr7-server

```

You need to have your [PSR-15](https://www.php-fig.org/psr/psr-15/) handler implementation to dispatch, and then, for example, dispatch it from an `index.php` file, as follows:

```
