Handling HTTP Requests

Home » Documentation » Handling HTTP Requests

The Conveyor Server has some customization points. That said, you can add an HTTP handler and make it able to handle HTTP requests and serve your website with it or any HTTP interface with it.

Here, we use the Conveyor Server Events. To know more, you can check here: Conveyor Server Events.

Here is an example of how to do that:


use Conveyor\ConveyorServer;
use OpenSwoole\Http\Request;
use OpenSwoole\Http\Response;
use Conveyor\Events\PreServerStartEvent;

$listeners = [
    ConveyorServer::EVENT_PRE_SERVER_START => fn (PreServerStartEvent $event) => 
        $event->server->on('request', function (Request $request, Response $response) {
           $response->end('Hello World!');

ConveyorServer::start(eventListeners: $listeners);