1. Go to this page and download the library: Download wp-php-toolkit/http-server 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/ */
wp-php-toolkit / http-server example snippets
WordPress\HttpServer\TcpServer;
use WordPress\HttpServer\IncomingRequest;
use WordPress\HttpServer\Response\ResponseWriteStream;
$server = new TcpServer( '127.0.0.1', 8080 );
$server->set_handler( function ( IncomingRequest $request, ResponseWriteStream $response ) {
$response->send_http_code( 200 );
$response->send_header( 'Content-Type', 'text/plain' );
$response->append_bytes( "Hello from " . $request->method . " " . $request->url . "\n" );
} );
$server->serve( function ( $host, $port ) {
echo "Listening on http://{$host}:{$port}\n";
} );