PHPackages                             drift/server - 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. drift/server

ActiveLibrary[Framework](/categories/framework)

drift/server
============

ReactPHP based server for DriftPHP

0.1.30(2y ago)6922.3k—5.4%14[4 issues](https://github.com/driftphp/server/issues)[1 PRs](https://github.com/driftphp/server/pulls)4MITPHPPHP ^7.4 || ^8.0CI failing

Since Nov 26Pushed 2y ago4 watchersCompare

[ Source](https://github.com/driftphp/server)[ Packagist](https://packagist.org/packages/drift/server)[ RSS](/packages/drift-server/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (17)Versions (32)Used By (4)

DriftPHP Server
===============

[](#driftphp-server)

[![CircleCI](https://camo.githubusercontent.com/0738799e3ebd48c89801f2a7537c4b211a9cabf0a873c3cfc4a3f22d2ebefaa7/68747470733a2f2f636972636c6563692e636f6d2f67682f64726966747068702f7365727665722e7376673f7374796c653d737667)](https://circleci.com/gh/driftphp/server)

This package provides a ReactPHP based async, reactive and non-blocking server for PHP applications working on top of ReactPHP Promises and PSR standards. The server has a small kernel/application abstraction for an optimized integration for several domain implementations. Here some features.

- Handle request based on Promises
- Serve static content in a non-blocking way
- Compress both Responses and Stream data
- Work with different workers, using multiple PHP threads (and CPUs)
- Visualize the usage and check how fast and light your request handles are
- Use the PHP-Watcher (only available if the PHP-Watcher is included in your composer) to automatically update the server if you change some of your code

By default, the server will use the DriftPHP Kernel adapter, but you can change the adapter easily when starting the server (Check the [adapters](#build-your-adapter)chapter)

### Table of content

[](#table-of-content)

- [Installation](#installation)
- [Start the server](#start-the-server)
- [Build your adapter](#build-your-adapter)
- [Workers](#workers)
- [Watcher](#watcher)
- [Static server](#static-server)
- [Symfony bridge](#symfony-bridge)
- [DriftPHP resources](#driftphp-resources)

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

[](#installation)

You can install the server by adding the dependency in your `composer.json`file

```
"require": {
    "drift/server": "^0.1"
}
```

Start the server
----------------

[](#start-the-server)

This package provides an async server for DriftPHP framework based on ReactPHP packages and Promise implementation. The server is distributed with all the Symfony based kernel adapters, and can be easily extended for new Kernel modifications.

To start the server, just type this line. Your project might have a custom `bin`folder, so check it.

```
php vendor/bin/server run 0.0.0.0:8000
```

You can use as well the short mode, defining only the port and assuming this host `0.0.0.0`.

```
php vendor/bin/server run 8000
```

And that's it. You will have a fully working server for your application.

Build your adapter
------------------

[](#build-your-adapter)

In order to build your adapter, the only thing you need is to create an implementation of the interface `Drift\Server\Adapter\KernelAdapter`. This layer will allow the server to start your application, handle each request, locate your static resources and shutdown the application. The `ObservableKernel` will provide as well some information about where your code is located, specifically designed for the watcher feature.

```
/**
 * Class KernelAdapter.
 */
interface KernelAdapter extends ObservableKernel
{
    /**
     * @param LoopInterface            $loop
     * @param string                   $rootPath
     * @param ServerContext            $serverContext
     * @param OutputPrinter            $outputPrinter
     * @param MimeTypeChecker          $mimeTypeChecker
     * @param FilesystemInterface|null $filesystem
     *
     * @return PromiseInterface
     *
     * @throws KernelException
     */
    public static function create(
        LoopInterface $loop,
        string $rootPath,
        ServerContext $serverContext,
        OutputPrinter $outputPrinter,
        MimeTypeChecker $mimeTypeChecker,
        ?FilesystemInterface $filesystem
    ): PromiseInterface;

    /**
     * @param ServerRequestInterface $request
     *
     * @return PromiseInterface
     */
    public function handle(ServerRequestInterface $request): PromiseInterface;

    /**
     * Get static folder.
     *
     * @return string|null
     */
    public static function getStaticFolder(): ? string;

    /**
     * @return PromiseInterface
     */
    public function shutDown(): PromiseInterface;
}
```

When you have your adapter created, the is as easy is this to start serving from your application

```
php vendor/bin/server run 0.0.0.0:8000 --adapter='My\Namespace\Adapter"
```

### Custom response output

[](#custom-response-output)

You can internally use the `x-server-message` header for custom server messages. The server will remove this server value before returning the response content.

Workers
-------

[](#workers)

This server creates a single worker by default. A simple PHP thread that will use one single CPUs. Luckily this server provides you a simple way of creating multiple instances listening the same port, emulating a simple balancer between N threads.

```
php vendor/bin/server run 0.0.0.0:8000 --workers=8
```

You can guess the number of physical threads your host has by using the value `-1`. By default, a single worker will be used.

This feature is not designed and intended for production environments. We encourage to use a reversed proxy or a small balancer if you need to balance between several processes. Furthermore, this feature uses `pcntl_fork`, so as the documentation explains it is not available for Windows users.

Watcher
-------

[](#watcher)

You can use the watcher by installing the `seregazhuk/php-watcher` dependency in your composer.

```
"require-dev": {
    "seregazhuk/php-watcher": "*"
}
```

After installing the dependency, you will be able to start your server by checking code changes.

```
php vendor/bin/server watch 0.0.0.0:8000
```

This feature is for development only.

Static server
-------------

[](#static-server)

This server can serve static files as well located in your project. By default, an adapter will provide a path where static files should be found (like DriftPHP statics are located under `public/` folder), but you can overwrite this value, or even override it.

```
php vendor/bin/server watch 0.0.0.0:8000 --static-folder=/my/own/folder/
php vendor/bin/server watch 0.0.0.0:8000 --no-static-folder
```

You can create an alias as well if you need it. That can be useful if you want to mask the internal path with an external one, only exposing this second one. Both values must be separated by the symbol `:`, being the first part the alias, and the second one the internal path.

```
php vendor/bin/server watch 0.0.0.0:8000 --static-folder=/public/:/internal/public/path
```

In this example, a file named `app.js` located under `/internal/public/path/`folder will be accessible at `http://localhost:8000/public/app.js`. By default, this feature is disabled.

### Static server cache

[](#static-server-cache)

You can define your static folder cache by adding a YAML file wherever you want and referencing it when starting the server.

```
php vendor/bin/server watch 0.0.0.0:8000 --static-cache=/my/path/static.cache.yml
```

In this file you can define specific headers for all your static resources (in fact, not only cache ones). You can define as well regular expressions for matching them.

```
/public/js/.*:
  Cache-Control: max-age=31536000
/public/css/app.js:
  Content-Type: application/javascript
/public/images/logo.png:
  Other-Header: Other-Value
```

By default, this feature is disabled and no extra headers will be added into your static resources.

### Important

[](#important)

By default, this package will not install the `react/filesystem` package. This means that, if you don't install it by hand in your project, all the disk operations will be blocking. These operations done synchronously will be much faster and efficient, but by using large size files could slow down the entire process.

Symfony bridge
--------------

[](#symfony-bridge)

In order to help you from migrating an application from Symfony to DriftPHP, assuming that this means that your whole domain should turn on top of Promises, including your infrastructure layer, this server is distributed with a small Symfony adapter. Use it as a tool, and never use it at production (using a ReactPHP based server in a blocking application is something not recommendable at all in terms of performance and service availability). That adapter will help your migrating from one platform to the other, as will allow this server to work with your Symfony kernel.

```
php vendor/bin/server watch 0.0.0.0:8000 --adapter=symfony
```

DriftPHP resources
------------------

[](#driftphp-resources)

Some first steps for you!

- [Go to DOCS](https://driftphp.io/#/?id=the-server)

or

- [Try a demo](https://github.com/driftphp/demo)
- [Install the skeleton](https://github.com/driftphp/skeleton)

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 91.2% 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 ~48 days

Recently: every ~182 days

Total

31

Last Release

962d ago

PHP version history (3 changes)0.1.0PHP &gt;=7.1

0.1.3PHP &gt;=7.3

0.1.17PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/e8cb88fa6413489c9cdb77288a06ff94b4553aa497d8fc0ee1891576053f1306?d=identicon)[mmoreram](/maintainers/mmoreram)

---

Top Contributors

[![mmoreram](https://avatars.githubusercontent.com/u/521409?v=4)](https://github.com/mmoreram "mmoreram (103 commits)")[![seregazhuk](https://avatars.githubusercontent.com/u/9959761?v=4)](https://github.com/seregazhuk "seregazhuk (6 commits)")[![Basster](https://avatars.githubusercontent.com/u/1265783?v=4)](https://github.com/Basster "Basster (1 commits)")[![nivpenso](https://avatars.githubusercontent.com/u/1158646?v=4)](https://github.com/nivpenso "nivpenso (1 commits)")[![petronetto](https://avatars.githubusercontent.com/u/8260778?v=4)](https://github.com/petronetto "petronetto (1 commits)")[![tomjvdberg](https://avatars.githubusercontent.com/u/47381148?v=4)](https://github.com/tomjvdberg "tomjvdberg (1 commits)")

---

Tags

driftphpreactphpserversocket

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M203](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k17.8k](/packages/prestashop-prestashop)

PHPackages © 2026

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