PHP code example of jose-chan / swoole-server

1. Go to this page and download the library: Download jose-chan/swoole-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/ */

    

jose-chan / swoole-server example snippets



try{
    /** @var \JoseChan\Swoole\Server\Server $server */
    $server = app()->make(\JoseChan\Swoole\Server\Server::class);
    $server->options()->task_worker_num = 2;
    $server->options()->daemonize = 1;

//    $server->event()->start(function (Server $server){
//        echo "server start";
//    });


    $server->start();
}catch (\Exception $e){
    echo $e->getMessage();
}



ons = new \JoseChan\Swoole\Utils\Options();
$options->worker_num = 10;
$options->max_request = 10;
$options->daemonize = 1;
$options->task_worker_num = 2;

$listener = new \JoseChan\Swoole\Utils\Listener("127.0.0.1", 8001);
$event = new \JoseChan\Swoole\Utils\Events();

$server = new \JoseChan\Swoole\Server\Server($options, $listener, $event);
$server->start();

`ssh
php artisan vendor:publish --tag=swoole-server