PHPackages                             statix/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. statix/server

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

statix/server
=============

A object oriented wrapper around PHP's built in server

0.5.0(3y ago)1172941MITPHPPHP &gt;=8

Since Jul 17Pushed 3y ago4 watchersCompare

[ Source](https://github.com/statix-php/server)[ Packagist](https://packagist.org/packages/statix/server)[ RSS](/packages/statix-server/feed)WikiDiscussions main Synced 1mo ago

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

Statix Server
=============

[](#statix-server)

Statix Server is a PHP package that provides a simple way to configure and start a local PHP server for your web development needs.

[![Banner image](.art/banner.jpg)](.art/banner.jpg)

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

[](#requirements)

- PHP 8 minumum

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

[](#installation)

You can install the package via composer:

```
composer require statix/server
```

View on packagist:

Basic Usage
-----------

[](#basic-usage)

To get started, require the vendor autoload script and create an instance of the `Server` class. After setting any [configuration options](#configuration), call the `start` method to start the server.

```
use Statix\Server\Server;

require_once './vendor/autoload.php';

Server::new()->start();

// or

(new Server)->start();
```

Configuration
-------------

[](#configuration)

You can configure the several options with the server, such as the host, the port, the root directory and more. Please read more below for a detailed explanation of each configuration method.

### Passing configuration via the constructor or Server::new()

[](#passing-configuration-via-the-constructor-or-servernew)

You may pass most configuration options via the constructor. For example we are setting the `host`, `port` and `root` options in the code below.

```
use Statix\Server\Server;

Server::new([
    'host' => 'localhost',
    'port' => 8000,
    'root' => __DIR__ . '/content'
]);

// or

new Server([
    'host' => 'localhost',
    'port' => 8000,
    'root' => __DIR__ . '/content'
]);
```

The complete list of configuration items that can be passed via the constructor can be found below.

```
$optionsSettableViaContructor = [
    'host' => 'string', // default: localhost
    'port' => 'string|int', // default: 8000
    'root' => 'string', // default: getcwd()
    'router' => 'string', // path to your routing script
    'php' => 'string', // path to the desired PHP binary to use for the server process
    'withEnvVars' => [
        'APP_DYNAMIC_ENV' => 'server'
    ],
    'withoutEnvVars' => [
        'APP_KEY'
    ]
];
```

### Setting configuration via named methods

[](#setting-configuration-via-named-methods)

You also have the option of calling named methods to set the configuration options as shown below.

```
use Statix\Server\Server;

Server::new()
    ->php('path')
    ->host('localhost')
    ->port('8080')
    ->root('./content')
    ->router('./router.php')
    ->withEnvVars([
        'APP_DYNAMIC_ENV' => 'server'
    ])->withoutEnvVars([
        'APP_KEY',
    ])->withEnvFile('path/to/.env');
```

### Capturing the output from the server process

[](#capturing-the-output-from-the-server-process)

If you want to show the output from the server process as it recieves and handles requests, you may call the `output` method and pass a callback function that will be called and passed any output of the process.

```
Server::new()
    ->output(function($output) {
        echo $output;
    })->start();
```

### Running the process in the background

[](#running-the-process-in-the-background)

You may find it useful to run the server process in the background, you may call `runInBackground()`. The process will run as long as the parent script is running.

```
Server::new()->runInBackground();
```

### Checking whether the process is running

[](#checking-whether-the-process-is-running)

You may check whether or not the server is currently running by calling the `isRunning` method.

```
$server = Server::new()->withEnvVars([
    'APP_NAME' => 'statix/server',
]);

$server->isRunning(); // false

$server->runInBackground();

$server->isRunning(); // true
```

### Stopping the server

[](#stopping-the-server)

You may stop the process running the sever by calling the stop command on an instance of the server class. If the server is not currently running this method will return `null` otherwise it will return an array container first the process exit code and second the process exit text. Note this command can only be called when the server is running in the background.

```
$server = Server::new()->runInBackground();

// do work

$server->stop();
```

### Restarting the server

[](#restarting-the-server)

You can restart the server by calling the `restart` method on an instance of the server class. An example of why you might need to restart the server is detecting when your `.env` file is changed, you could restart the server and ensure the env vars are loaded.

```
$server = Server::new()->runInBackground();

// do work

$server->restart();

// do more work

$server->stop();
```

Contributing
------------

[](#contributing)

#### Installation

[](#installation-1)

1. Clone repo

```
git clone https://github.com/statix-php/server.git

```

2. Install php dependencies

```
composer install

```

#### Testing

[](#testing)

We use [Pest PHP](https://pestphp.com/) for the test suite, please ensure before pushing changes you confirm there are no breaking changes by running the command below. Additionally, tests for new features are highly encouraged, changes will be considered without tests but it will increase the time to accept / merge.

```
./vendor/bin/pest

```

#### Style

[](#style)

We use [Laravel Pint](https://github.com/laravel/pint) to automatically standardize code styling, before pushing changes please run `pint` using the command below.

```
./vendor/bin/pint

```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

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

Recently: every ~56 days

Total

9

Last Release

1170d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ec1f5d67a8ace8451f50303ed7fc9185a8298b9a38dc4d47c3aeb283255e66d?d=identicon)[wyattcast44](/maintainers/wyattcast44)

---

Top Contributors

[![WyattCast44](https://avatars.githubusercontent.com/u/17957937?v=4)](https://github.com/WyattCast44 "WyattCast44 (25 commits)")

---

Tags

phpserverstatixstatix-php

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[keepsuit/laravel-temporal

Laravel temporal.io

4875.0k](/packages/keepsuit-laravel-temporal)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[melios/page-builder

Improvements for the built-in Magento PageBuilder module

131.4k](/packages/melios-page-builder)

PHPackages © 2026

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