Skip to content

Workerman

A PHP framework for building fast, event-driven network servers over HTTP, WebSocket, and TCP.

Stars
11.5k
Forks
2.2k
Licence
MIT
Language
PHP
Last update
13 days ago
Type
Library

What it is

Workerman is a PHP framework for writing network servers that handle many connections at once without blocking. It supports HTTP, WebSocket (including secure wss via SSL), TCP, and custom protocols. Developers use it to build things like real-time chat, push messaging, or other services that need to keep many open connections.

  • Run a WebSocket server that echoes or broadcasts messages to connected clients
  • Serve HTTP requests from a PHP process that stays running
  • Open a WebSocket client connection to another server using AsyncTcpConnection
  • Enable secure wss:// connections by supplying an SSL certificate and key
  • Use coroutines, Barrier, Parallel, or Channel for concurrent tasks when the Swoole, Swow, or Fiber event loop is available

Great for

  • PHP developers who need a long-running socket or WebSocket server
  • Teams building real-time features such as chat or live notifications in PHP
  • Developers who want to write custom TCP or binary protocols in PHP
  • Projects that need high concurrency and can run PHP on a POSIX system

Not ideal for

  • People who only need a standard request-per-page PHP website, since Workerman runs as its own long-lived process
  • Users on Windows, because the README says it requires a POSIX-compatible OS (Linux, OSX, BSD)
  • Teams without PHP experience, since it requires understanding event-driven code
Step-by-step guide: how to use WorkermanInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: PHP with POSIX and PCNTL extensions · Composer

    Install via Composer

    composer require workerman/workerman
  2. 2

    Run it

    • Install the package with Composer in your project
    • Create a PHP file that requires vendor/autoload.php and defines a Worker, such as the WebSocket example in the README
    • Run the script from the command line; Worker::runAll() starts the server
    • Connect a WebSocket client to the port you chose, for example 2346 in the README example
  3. 3

    Get the most out of it

    • Install the Swoole, Swow, or Event extension to improve performance, as the README recommends
    • Use the eventLoop setting with Swoole::class, Swow::class, or Fiber::class to enable coroutines
    • Set the count property on a Worker to run several processes for higher throughput
    • Use Barrier or Parallel to run concurrent tasks and collect their results
    • Read the official manual at manual.workerman.net for configuration details

Downloads

Strengths

  • Built for asynchronous, event-driven networking with multiple protocols in one framework
  • Supports HTTP, WebSocket, SSL, and custom protocols as described in the README
  • Installs with a single Composer command and is MIT licensed

Trade-offs

  • Requires the POSIX and PCNTL extensions, and Swoole, Swow, or Event is recommended for better performance
  • Coroutine features depend on an optional extension or the Fiber event loop, adding setup choices
  • The README is truncated, so details of the full API and production deployment are only available in the external manual

How it compares

ProjectStarsTypeLevelUpdatedBest for
workerman (this)11.5kLibraryintermediate13 days agoPHP developers who need a long-running socket or WebSocket server
ratchet14.7kLibrarybeginner1.6 years agoDevelopers prototyping a mobile-style web interface with plain HTML, CSS and JS
tokio33.6kLibraryadvanced5 days agoRust developers building network servers or clients
libuv27.3kLibraryadvanced5 days agoDevelopers building networked or I/O-heavy software in C or a language with C bindings
guzzle23.4kLibraryintermediate11 days agoPHP developers who need to call external REST or web service APIs
monolog21.4kLibraryintermediate5 days agoPHP developers who need structured logs from an application

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.