PHP code example of wilbur-yu / hyperf-server-switch

1. Go to this page and download the library: Download wilbur-yu/hyperf-server-switch 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/ */

    

wilbur-yu / hyperf-server-switch example snippets


'servers' => [
        [
            'name'      => 'http',
            'type'      => Server::SERVER_HTTP,
            'host'      => '127.0.0.1',
            'port'      => 9801,
            'sock_type' => SWOOLE_SOCK_TCP,
            'callbacks' => [
                Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'],
            ],
        ],
        [
            'name'      => 'http2',
            'type'      => Server::SERVER_HTTP,
            'host'      => '0.0.0.0',
            'port'      => 9502,
            'sock_type' => SWOOLE_SOCK_TCP,
            'callbacks' => [
                Event::ON_REQUEST => ['HttpServer2', 'onRequest'],
            ],
        ],
    ],
bash
php bin/hyperf.php start
bash
php bin/hyperf.php -S http

// or

php bin/hyperf.php -S http2