中文 | English
workbunny/webman-coroutine
🐇 Webman Coroutine Infrastructure Suite Compatible with Workerman. 🐇
This document was translated by AI. If there are any inaccuracies or if any part is unclear, please refer to the original Chinese document or email for clarification. Corrections to the document are welcome.
🚀🐇 webman-coroutine is a coroutine infrastructure support plugin for the
workerman
/webman
development framework ecosystem
Workerman 4.x
and thewebman
framework based on it as a runtime container do not support coroutinesWorkerman 5.x
and thewebman
framework based on it as a runtime container do not have complete coroutine capabilities- There is no unified way to use coroutines in
workerman
/webman
, leading to high development and trial costs when switching coroutine drivers - Implementing coroutine versions of workers and servers on your own has high development and trial costs
The origin of the workbunny/webman-coroutine plugin and coroutine development sharing
-
Provide various basic coroutine event libraries for
workerman
/webman
, compatible with coroutine drivers for workerman 4.x and workerman 5.x -
Provide unified coroutine development tools for
workerman
/webman
, compatible with non-coroutine environments- Coroutine channel: Utils/Channel
- Coroutine wait group: Utils/WaitGroup
- Coroutine: Utils/Coroutine
- Coroutine Worker: Utils/Worker
- Object pool: Utils/Pool
- Provide a simple coroutine toolkit in the
workerman
/webman
development environment to reduce cognitive load. - Attempt to implement a solution in the
workerman
/webman
development environment that is compatible with both coroutine and non-coroutine development, making it easier to choose and abandon solutions, reducing anxiety. - Try to achieve non-intrusive coroutine modifications to official components in the
workerman
/webman
development environment (although it’s difficult, we want to try). - Hope to provide some help, or even inspiration, to more PHP developers with the implementation of our code.
Install via composer:
composer require workbunny/webman-coroutine
|-- config # webman configuration files
| |-- plugin
| |-- webman-coroutine
| |-- app.php # main configuration
| |-- process.php # start process
|-- Events # workerman-4.x event-driven files
|-- Exceptions # exceptions
|-- Handlers # main driver entry
|-- Utils # toolkit
| |-- Channel # channel driver
| |-- Coroutine # coroutine driver
| |-- WaitGroup # wait group driver
| |-- Worker # worker driver
| |-- Pool # object pool driver
| |-- RegisterMethods.php # driver registration helper
|-- Factory # entry class
|-- CoroutineWebServer.php # custom http server for webman
|-- helpers.php # entry helper
event_loop()
used to automatically determine the suitable event loop and coroutine driver for the current environmentThe environment is automatically determined in the order of Factory::$_handlers
package_installed
used to determine whether the corresponding composer package is installed in the current environmentwait_for
used for non-blocking waiting of corresponding conditions in the process (usually the result of child coroutine execution)is_coroutine_env
used to determine whether the current environment is a workbunny coroutine environmentAfter installing
workbunny/webman-coroutine
, the environment variableWORKBUNNY_COROUTINE=1
will be automatically registered
Directory | Address |
---|---|
API | Fucntion-APIs |
Tutorial | Introduction to PHP Coroutine |
- | Installation and Configuration |
- | Helper Functions |
- | workerman Environment |
- | webman Framework |
- | Explanation of Utils |
- | Custom Extensions |
-
For new feature submissions, please submit a feature issue before submitting a PR to avoid duplicate development;
-
For bug fixes, please submit a bug report issue before submitting a PR to avoid duplicate development;
- Code formatting:
composer cs-fix
- Static analysis:
composer php-stan
- Testing and coverage:
composer unit-test
, the command will generate a report in thecoverage
directory created in the project - function-apis documentation generation:
- Use
composer doc-install
or installphpDocumentor
yourself - Use
phpDocumentor
to generate documentation in the root directory of the project
- Use
- How to use swow event-driven and coroutine in webman?
- Swow: A high-performance pure coroutine network communication engine for PHP
- How to implement one-click coroutine with workerman5.0 and swoole5.0
- How to use swoole event-driven and coroutine in webman?
Grateful to the workerman and swow development teams for their innovation and excellent contributions to the PHP community. Let's look forward to more breakthroughs in PHP for real-time applications!!!