PHP code example of runtime / swoole-nyholm

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

    

runtime / swoole-nyholm example snippets


// public/index.php

use Swoole\Http\Request;
use Swoole\Http\Response;

esponse) {
        $response->header("Content-Type", "text/plain");
        $response->end("Hello World\n");
    };
};

// public/index.php

use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;

'] ?? 'World';
        return new Response(200, ['Server' => 'swoole-runtime'], "Hello, $name!");
    }
}

return function(): RequestHandlerInterface {
    return new App();
};

// public/index.php

use App\Kernel;

$_SERVER['APP_RUNTIME_OPTIONS'] = [
    'host' => '0.0.0.0',
    'port' => 9501,
    'mode' => SWOOLE_BASE,
    'settings' => [
        'worker_num' => swoole_cpu_num() * 2,
        'enable_static_handler' => true,
        'document_root' => dirname(__DIR__) . '/public'
    ],
];