PHPackages                             karmabunny/visor - 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. [CLI &amp; Console](/categories/cli)
4. /
5. karmabunny/visor

ActiveLibrary[CLI &amp; Console](/categories/cli)

karmabunny/visor
================

A supervisor for PHP-CLI servers

v2.2.5(7mo ago)02.1k↓35.9%1[1 PRs](https://github.com/Karmabunny/visor/pulls)2MITPHPCI passing

Since Jan 30Pushed 7mo ago4 watchersCompare

[ Source](https://github.com/Karmabunny/visor)[ Packagist](https://packagist.org/packages/karmabunny/visor)[ RSS](/packages/karmabunny-visor/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (5)Versions (10)Used By (2)

Visor
=====

[](#visor)

This is a small utility to wrap the built-in PHP [cli-server](https://www.php.net/manual/en/features.commandline.webserver.php) feature.

There are two three parts to this library:

1. An abstract 'server' instance that will manage the lifecycle of any cli-server compatible script.
2. An 'echo server' implementation that, uh, echos. What you say at it, it says back.
3. A 'mock server' implementation that will reply with defined responses.

Install
-------

[](#install)

Using Composer:

```
composer require karmabunny/visor

```

Usage
-----

[](#usage)

This is ideal for creating small integration tests with a local application or creating mock servers and testing HTTP libraries.

### Server Instance

[](#server-instance)

```
use karmabunny\visor\Server;
use PHPUnit\Framework\TestCase;

/**
 * The application bootstrap is found at: 'index.php'. This must be capable
 * of accepting cli-server requests.
 */
class MyServer extends Server
{
    protected function getTargetScript(): string
    {
        return __DIR__ . '/index.php';
    }
}

class MyServerTest extends TestCase
{
    public function testThings()
    {
        // This create a server at localhost:8080
        $server = MyServer::create();

        // One can then perform tests against the application.
        $res = file_get_contents($server->getHostUrl() . '/health');
        $this->assertEquals('ok', $res);
    }
}
```

### Echo Server

[](#echo-server)

```
use karmabunny\visor\EchoServer;
use PHPUnit\Framework\TestCase;

class ClientTest extends TestCase
{
    public function testThings()
    {
        // This creates an echo server at localhost:8080
        $server = EchoServer::create();

        // Imagine this to be some kind of client that hits a remote
        // server of sorts.
        $res = file_get_contents($server->getHostUrl() . '/hello?test=123');

        // Not only is 'res' a JSON body of the payload, the payload is
        // also accessible from the the server instance.

        $payload = $server->getLatestPayload();

        $this->assertEquals('/hello', $payload['path']);
        $this->assertEquals(['test' => '123'], $payload['query']);
    }
}
```

### Mock Server

[](#mock-server)

```
use karmabunny\visor\MockServer;
use PHPUnit\Framework\TestCase;

class FakeTest extends TestCase
{
    public function testThings()
    {
        // This creates a mock server at localhost:8080
        $server = MockServer::create();

        $server->setMock('/mock-this', [], 'a fake response');
        $res = file_get_contents($server->getHostUrl() . '/mock-this');

        $payload = $server->getLatestPayload();

        $this->assertEquals('/mock-this', $payload['path']);
        $this->assertEquals('a fake response', $res);
    }
}
```

Config
------

[](#config)

name-defaulthosta binding addresslocalhostportHTTP port number8080waitpause until the server is ready (milliseconds)100pathworking directory of the server-By default the log file path is randomised in a temporary system directory.

Log files
---------

[](#log-files)

The server emit a log file to aid testing and debugging.

This includes logs from the server process, the application, and visor itself.

Server that extend the base class can use `Server::log()`. Applications can use the native `error_log()`.

### Mock + Echo Server

[](#mock--echo-server)

The included implementations will log additional data also.

- `latest.json` is the request payload stored for introspection. Used by `getLastPayload()`.
- `mocks.json` is a store of response objects for the mock server.

Echo (+ Mock) payloads
----------------------

[](#echo--mock-payloads)

Both Mock and Echo servers store the request object in a specific format.

Note that the body is unchanged, if you've sent a JSON or URL payload this will be 'as is' in it's encoded string form.

- `path` - the request path, without the query string
- `query` - an key-value array, from `parse_str()`
- `method` - always uppercase
- `headers` - key-value pairs, keys are lowercase
- `body` - string body, from `php://input`

The JSON-encoded log file looks like this:

```
{
    "path": "/hello-world.json",
    "query": {
        "rando1": "7bb1166f0cf451cc3eb4cbb977ad932f674aac6c"
    },
    "method": "POST",
    "headers": {
        "host": "localhost:8080",
        "connection": "close",
        "content-length": "53",
        "content-type": "application/json"
    },
    "body": "{\"rando2\":\"267f3bf70d8939c2c7e77d1f8ea164e1df071bba\"}"
}
```

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance63

Regular maintenance activity

Popularity22

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity52

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

Recently: every ~0 days

Total

9

Last Release

223d ago

Major Versions

v1.1.0 → v2.1.02025-11-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/11b33084210490439a6fb2c0b277e0bf39f8d0e368f20bebb703834003a617df?d=identicon)[karmabunny](/maintainers/karmabunny)

---

Top Contributors

[![gwillz](https://avatars.githubusercontent.com/u/3466850?v=4)](https://github.com/gwillz "gwillz (64 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/karmabunny-visor/health.svg)

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

###  Alternatives

[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k127.1M203](/packages/sentry-sentry-laravel)[bref/bref

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k10.6M67](/packages/bref-bref)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[buggregator/trap

A simple and powerful tool for debugging PHP applications.

2702.2M68](/packages/buggregator-trap)[mollie/mollie-api-php

Mollie API client library for PHP. Mollie is a European Payment Service provider and offers international payment methods such as Mastercard, VISA, American Express and PayPal, and local payment methods such as iDEAL, Bancontact, SOFORT Banking, SEPA direct debit, Belfius Direct Net, KBC Payment Button and various gift cards such as Podiumcadeaukaart and fashioncheque.

60216.0M85](/packages/mollie-mollie-api-php)

PHPackages © 2026

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