PHPackages                             phvia/firman - 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. phvia/firman

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

phvia/firman
============

PHP multi-process and non-blocking I/O library.

221PHP

Since Oct 8Pushed 7y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (3)Used By (0)

Firman
======

[](#firman)

PHP multi-process and non-blocking I/O library.

Dependency
----------

[](#dependency)

- PHP&gt;=7. (for new features and high performance)
- PCNTL extension. (compile PHP with `--enable-pcntl` option to enable)
- Sockets extension. (compile PHP with `--enable-sockets` option to enable)

Install
-------

[](#install)

```
$ composer require phvia/firman:dev-master
```

Run example
-----------

[](#run-example)

- Show usage

```
$ php /path/to/firman/examples/via_websocket_serv_builtin.php

Firman package 0.0.1

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help     Displays help for a command
  list     Lists commands
  restart  Restart Firman server
  start    Start Firman server
  stop     Stop Firman server
```

- Show usage detail

```
$ php /path/to/firman/examples/via_websocket_serv_builtin.php start -h

Usage:
  start [options]

Options:
  -e, --env=ENV         The Environment name (support: dev, prod) [default: "dev"]
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Start Firman server
```

- Process control

```
# After start server, you can access examples/ws.html in web browser
$ php examples/via_websocket_serv_builtin.php start

# Restart Firman server
$ php examples/via_websocket_serv_builtin.php restart

# Stop Firman server
$ php examples/via_websocket_serv_builtin.php stop
```

- Run in daemon

```
$ php /path/to/firman/xxx.php start --env=prod
# OR
$ php /path/to/firman/xxx.php start --eprod
$
$ ps auxf | grep Firman
```

Do it yourself
--------------

[](#do-it-yourself)

- Simplest configure

```
include '/path/to/vendor/autoload.php';

(new \Firman\Server('tcp://0.0.0.0:8080'))->run();
```

- Full configure

```
inlcude '/path/to/vendor/autoload.php';

$server = new \Firman\Server();

$socket = 'tcp://0.0.0.0:8080';

$server
    // Parameter.

    // optional, default is 1
    // Set child process number
    ->setCount(1)

    // optional, can also be in constructor
    // Set socket
    ->setSocket($socket)

    // optional, default is Firman
    // Set process title
    ->setProcessTitle('Firman')

    // optional, default is /tmp
    // Set the path of file saved ppid
    ->setPpidPath('/tmp')

    // optional, default is 100
    // Set socket backlog number
    ->setBacklog(100)

    // optional, default is 200
    // Set select system call timeout value
    ->setSelectTimeout(5)

    // optional, default is 60
    // Set accept timeout value
    ->setAcceptTimeout(10)

    // Event callback.

    // optional, when client connected with server, callback trigger.
    // Set connection event callback task
    ->onConnection(function($connection) {
        echo "New client connected." . PHP_EOL;
    })

    // optional, when client send message to server, callback trigger.
    // Set message event callback task
    ->onMessage(function($connection) {
        // implement your logic
    })

    // Run server.

    ->run();
```

Server workflow explain
-----------------------

[](#server-workflow-explain)

- Check environment.
- Parse command.
- Initialize master process information.
- Fork child process, install signal for child, poll on child.
- Create socket server (like: create socket, bind, listen, set option).
- Block on master, monitor any child process and restart who exited.

Tests
-----

[](#tests)

```
$ ./vendor/bin/phpunit --bootstrap=vendor/autoload.php tests
```

Todo
----

[](#todo)

Our position is focus on socket :

- Implement protocol parse built-in.
- Support Unix domain, UDP, ect.
- Robustness.

Resources:
----------

[](#resources)

Composer Document:

Symfony Console Component:

Contribute:
-----------

[](#contribute)

Any pull requests to improve **phvia/firman** are welcome.

Coding style follow PSR2:
Using PHP\_CodeSniffer tool: [https://github.com/squizlabs/PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
Running check: `php phpcs.phar --standard=psr2 ./`

Recommend Coding Standards:

Group
-----

[](#group)

QQ group: 377154148

License
-------

[](#license)

[MIT](https://github.com/phvia/firman/blob/master/LICENSE)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6552412?v=4)[ethan](/maintainers/farwish)[@farwish](https://github.com/farwish)

---

Top Contributors

[![farwish](https://avatars.githubusercontent.com/u/6552412?v=4)](https://github.com/farwish "farwish (23 commits)")

---

Tags

firmanmulti-processnon-blocking-iophp-socketphp7socket

### Embed Badge

![Health badge](/badges/phvia-firman/health.svg)

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

###  Alternatives

[willdurand/geocoder

Common files for PHP Geocoder

17435.7M159](/packages/willdurand-geocoder)

PHPackages © 2026

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