PHP code example of reactphp-x / micro-service
1. Go to this page and download the library: Download reactphp-x/micro-service library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
reactphp-x / micro-service example snippets
use ReactphpX\MicroService\ServerMiddleware;
use ReactphpX\RegisterCenter\Register;
use React\Http\HttpServer;
use React\Socket\SocketServer;
// Initialize the register center
$register = new Register(8010);
// Create the server middleware
$middleware = new ServerMiddleware($register);
// Setup HTTP server
$server = new HttpServer($middleware);
// Listen on port 8080
$socket = new SocketServer('127.0.0.1:8080');
$server->listen($socket);