This repository has been archived on 2017-08-18. You can view files and clone it, but cannot push or open issues or pull requests.
workerman-uv/README.md

36 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Workerman-Uv
### 简介
[libuv](http://libuv.org/) 是一个事件驱动的异步 I/O 库,最初是为 Node.js 开发的。随后也在 Python、Julia 等语言中被应用。
[php-uv](https://pecl.php.net/package/uv) 是对 libuv 的封装,使其可以在 PHP 中被应用。
本项目将 php-uv 的 event-loop 应用于 Workerman从而可以在基于 Workerman 的项目中利用 php-uv 提供的特性。
### 使用说明
1. 使用包管理器安装 libuv 和 libuv-devel可能需要手动添加源
2. 使用 pecl 安装 php-uv也可以从 pecl 官网或 GitHub 仓库下载源码后手动编译)。
3. 使用 composer 加载`Workerman\\Events\\Uv`。
```bash
composer require cismonx/workerman-uv
```
4. 在项目中使用 `Workerman\Events\Uv` 提供的 event-loop。如下
```php
Worker::$eventLoopClass = '\\Workerman\\Events\\Uv';
```
### 注意
1. 使用 libuv 的 event-loop 后Workerman 的子进程处理 SIGINT 事件时会 exit 2 (no such file or directory),这个问题待解决。
2. 如果需要使用 libuv 的多线程特性需要线程安全ZTS的 PHP。
3. php-uv 目前处于 Beta 阶段,其稳定性不能保证。请避免将其应用于生产环境。