PHPackages                             madkom/simple-http - 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. madkom/simple-http

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

madkom/simple-http
==================

Simple HTTP Server w/o concurrency

0.1.4(9y ago)121MITPHP

Since Feb 21Pushed 8y ago4 watchersCompare

[ Source](https://github.com/madkom/simple-http)[ Packagist](https://packagist.org/packages/madkom/simple-http)[ RSS](/packages/madkom-simple-http/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (6)Used By (0)

Simple HTTP Server
==================

[](#simple-http-server)

Simple HTTP Server w/o concurrency in PHP

Install
-------

[](#install)

With *Composer*

```
composer require madkom/simple-http
```

Usage
-----

[](#usage)

Simple usage:

```
namespace Madkom\SimpleHTTP;

$server = new Server('0.0.0.0', $argc > 1 ? (int)$argv[1] : 80);
$server->run(function (Request $request) : Response {
    return new Response(200, "Requested path: {$request->getPath()}");
});
```

Advanced:

```
namespace Madkom\SimpleHTTP;
$data = [];
$cache = [];

$server = new Server('0.0.0.0', $argc > 1 ? (int)$argv[1] : 80);
$server
    ->get('/config', function (Request $request) use (&$data, &$cache) : Response {
        if (\array_key_exists('config', $cache)) {
            return $cache['config'];
        }
        return $cache['config'] = new JsonResponse(200, \array_keys($data));
    })
    ->get('/{name}', function (Request $request, string $name) use (&$data, &$cache) : Response {
        if (\array_key_exists($name, $cache)) {
            return $cache[$name];
        }
        if (false === \array_key_exists($name, $data)) {
            return new Response(404);
        }
        return $cache[$name] = new JsonResponse(200, $data[$name]);
    })
    ->put('/{name}', function (Request $request, string $name) use (&$data, &$cache) : Response {
        $json = \json_decode($request->getContent(), true);
        if (empty($json) && \json_last_error()) {
            return new Response(400, 'Malformed request: ' . \json_last_error_msg());
        }
        $data[$name] = \array_key_exists($name, $data) ? \array_merge($data[$name], (array)$json) : $json;
        unset($cache[$name], $cache['status']);
        return new Response(204);
    })
    ->post('/{name}', function (Request $request, string $name) use (&$data, &$cache) : Response {
        $json = \json_decode($request->getContent(), true);
        if (empty($json) && \json_last_error()) {
            return new Response(400, 'Malformed request: ' . \json_last_error_msg());
        }
        $data[$name] = \array_key_exists($name, $data) ? \array_merge($data[$name], (array)$json) : $json;
        unset($cache['status']);
        return $cache[$name] = new JsonResponse(200, $data[$name]);
    })
    ->run(function (Request $request, string $path) use (&$cache) : Response {
        if ($path === '/') {
            if (\array_key_exists('', $cache)) {
                return $cache[''];
            }
            $routes = \implode(\PHP_EOL, \array_map(function (Route $route) : string {
                return (string)$route;
            }, $this->router->getRoutes()));
            return $cache[''] = new Response(200, "{$routes}", [
                'Content-Type' => 'text/html',
            ]);
        }
        $this->log("Bad request({$request->getMethod()} {$request->getPath()})", "\033[0;33m");
        return new Response(400);
    });
```

License
-------

[](#license)

MIT License

Copyright (c) 2017 Madkom

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

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

Total

5

Last Release

3402d ago

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/406fcac8020975863dc6ca1f7cf729eb9755911131bce696ba502218c0536be5?d=identicon)[Madkom](/maintainers/Madkom)

---

Top Contributors

[![brzuchal](https://avatars.githubusercontent.com/u/3149753?v=4)](https://github.com/brzuchal "brzuchal (9 commits)")

### Embed Badge

![Health badge](/badges/madkom-simple-http/health.svg)

```
[![Health](https://phpackages.com/badges/madkom-simple-http/health.svg)](https://phpackages.com/packages/madkom-simple-http)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25025.5M80](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87930.4k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.3M84](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69122.6k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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