1. Go to this page and download the library: Download upscale/swoole-dispatch 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/ */
upscale / swoole-dispatch example snippets
$server = new \Swoole\Http\Server('127.0.0.1', 8080);
$server->set([
'dispatch_func' => new \Upscale\Swoole\Dispatch\FixedClient(),
]);
$server->on('request', function ($request, $response) use ($server) {
$response->header('Content-Type', 'text/plain');
$response->end("Served by worker {$server->worker_id}\n");
});
$server->start();
$server->set([
'dispatch_func' => new \Upscale\Swoole\Dispatch\RoundRobin(),
]);
$server->set([
'dispatch_func' => new \Upscale\Swoole\Dispatch\StickySession(
new \Upscale\Swoole\Dispatch\RoundRobin()
),
]);
$server->set([
'dispatch_func' => new \Upscale\Swoole\Dispatch\UrlPath(
new \Upscale\Swoole\Dispatch\RoundRobin()
),
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.