Swoole is another effort to bring event-driven async features to PHP:
Swoole is an event-driven, asynchronous & concurrent networking communication framework with higher performance written only in C for PHP.
While I’m not sure about using this as an application server for PHP ( I have mixed feelings about PHP app servers in general ), I do like their TCP server example:
[sourcecode lang=”php”]
$serv = new swoole_server("127.0.0.1", 9501);
$serv->set(array(
‘worker_num’ => 8,
‘daemonize’ => true,
));
$serv->on(‘connect’, function ($serv, $fd){
echo "Client:Connect.n";
});
$serv->on(‘receive’, function ($serv, $fd, $from_id, $data) {
$serv->send($fd, ‘Swoole: ‘.$data);
$serv->close($fd);
});
$serv->on(‘close’, function ($serv, $fd) {
echo "Client: Close.n";
});
$serv->start();
[/sourcecode]