Workerman is a highly efficient tool for building asynchronous servers in PHP. It is designed for working with WebSockets, HTTP servers, chat applications, APIs, and other network-based applications.
Workerman works without the need for additional extensions or dependencies since it is fully implemented in pure PHP. This makes it cross-platform and simple to install.
Notably, Workerman supports both HTTP and HTTPS, allows working with WebSockets, and easily scales to handle a large number of connections concurrently. This makes it suitable for creating realtime applications, such as chat systems, notification services, and streaming servers.
For the application to function correctly when launched using this technology, it must be developed with support for asynchronous mode.
Under the term "asynchrony" this document groups together true asynchronous mode and the conventional long-running mode, since the recommendations for both are identical.
In asynchronous mode, the loaded framework configurations, classes, initialized services, and cached data are reused, which significantly accelerates performance.
However, there are distinctive features, such as the need to monitor memory leaks more closely and eliminate blocking operations, and many familiar third-party libraries do not support asynchronous mode.
Storing state in the logical parts of the application becomes undesirable, especially if it is related to a request.
The framework interfaces ResetInterface and RollbackInterface are intended for resetting state after each asynchronous request.
You can install Workerman via Composer as a standard PHP library. More details can be found in the installation guide.
Under Workerman, you need to modify the /public/index.php file so that the HLEB2 framework runs in a loop.
Basic working example:
The Workerman server is started with the following console command:
$php ./public/index.php start
According to the specified settings, the application will be available at: http://127.0.0.1:2345
← Running with Roadrunner Swoole Server →