Serving multiple Twirp services together

In some cases you might want to serve not just one, but multiple services from one application. The shared library contains a simple server implementation which lets you mux different services.


$server = new \Twirp\Server();

// register services
    new \Twitch\Twirp\Example\HaberdasherServer(
        new \Twirphp\Example\Haberdasher()

Both the server and service server implement the PSR-15 RequestHandler interface, so you can use the same code as in the Run the server usage example:


// ...
$response = $server->handle($request);