Skyray
A Promise based networking library for PHP written in C
Install / Use
/learn @SkyrayLabs/SkyrayREADME
Skyray - A networking library for PHP written in C
Skyray provides non-blocking I/O and multi-processing facilities for PHP, it is intended be to as flexible as possible to suit for various applications.
Features
- Well designed OO interfaces for I/O and Process management
- Stream oriented abstraction, everything is stream, simple and clean
- Build servers with PHP, quick and easy
- Support both non-blocking and blocking interfaces
- Support millisecond timer (both periodic and non-periodic)
- Bring all possibilities to PHP world ...
Installation
git clone https://github.com/SkyrayLabs/Skyray.git --recursive
phpize
./configure --with-php-config=/path/to/php-config
make & make install
NOTES : Skyray requires PHP7, please be sure your have php7 installed before building.
Examples
A Simple Echo Server
server.php
use skyray\Reactor;
use skyray\stream\Server;
use skyray\stream\ProtocolInterface;
class SimpleEchoProtocol implements ProtocolInterface
{
protected $debug;
protected $stream;
public function __construct($debug = false)
{
$this->debug = $debug;
}
public function log($info)
{
echo '[server]: ' . $info . PHP_EOL;
}
public function connectStream($stream)
{
$this->stream = $stream;
}
public function streamConnected()
{
$this->debug && $this->log('connected');
}
public function dataReceived($data)
{
$this->log('received data: ' . $data);
$this->stream->write($data);
}
public function streamClosed()
{
$this->debug && $this->log('closed');
}
}
$reactor = new Reactor();
$server = new Server(function () {
return new SimpleEchoProtocol(true);
}, $reactor);
$server->listen('0.0.0.0', 10000);
$reactor->run();
client.php
use skyray\stream\Client;
$client = new Client();
$stream = $client->connectTCP('127.0.0.1', 10000);
$stream->write('hello world');
var_dump($stream->read());
$stream->close();
Documentation
Documentation is not yet available, please refer here for prototype of all classes.
Participating
Skyray is still in active development, your participating is very wellcome!
You may participate in the following ways:
- Report issues or Start a design discussion
- Develop features or write documentation via Pull Requests
Related Skills
node-connect
353.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
353.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
353.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。

