Wallogit.com
2017 © Pedro Peláez
A PHP framework to develop WebSocket, HTTP and FCGI Applications
EmitPHP is a PHP framework that works with non-blocking I/O., (*1)
You can write your web applications and APIs in HTTP, FCGI and WebSocket., (*2)
As of now, this is an experimental project and there still exists errors and bugs., (*3)
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer
composer install
Now you can run Examples, (*4)
Yes, EmitPHP supports WebSocket., (*5)
you can create your WebSocket Application with a few lines of code., (*6)
Below is an example of how to create a WebSocket Application., (*7)
// Create a new WS Application
$app = (new WSServer())->listen(4000)->app();
// Triggers when messages received
$app->on('message', function($conn, $msg){
// Echo message
$conn->send("echo => ". $msg);
// Close the connection
$conn->close();
});
\Emit\Loop();
You can easily create a HTTP server as below, (*8)
$server = (new HTTPServer())->listen(4000);
$server->on('request', function($req, $res){
// Send response
$res->send("Hello World");
// Close connection
$res->end();
});
\Emit\Loop();
Example for using Router, (*9)
$server = (new HTTPServer())->listen(9000);
// Create a new Route
$route = $server->route();
// Get method
$route->get("/", function($req, $res, $next){
$res->send("Hello World");
// Calling the next handler
$next();
});
// Register the route
$server->use($route);
\Emit\Loop();
EmitPHP supports FCGI which works with Web Servers such as apache, (*10)
$server = (new FCGIServer())->listen(9000);
$server->on('request', function($req, $res){
// Send response
$res->send("Hello World");
// Close connection
$res->end();
});
\Emit\Loop();
See examples for more details., (*11)
Please send me your feeback at emitphp@gmail.com and let me know how you like it. If there are demands, I will work more., (*12)
And if any of you wants to join the project, please let me know., (*13)
EmitPHP is licensed under the MIT license. See License File for more information., (*14)