PHP Classes

File: test-swoole.php

Recommend this page to a friend!
  Classes of Ahmad Mustapha  >  PHP Application Server  >  test-swoole.php  >  Download  
File: test-swoole.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Application Server
Run application with different types of Web server
Author: By
Last change:
Date: 2 months ago
Size: 688 bytes
 

Contents

Class file image Download
<?php

use PHPServer\Swoole\Http\Request;
use
PHPServer\Swoole\Server;

require
'vendor/autoload.php';

$handler = function (Request $request) {
   
$html = 'Welcome,<br/>';
   
$html .= "Method: {$request->getMethod()}<br/>";
   
$html .= "Route: {$request->getUri()->getPath()}";
   
$request->response()->html($html);
};

$paths = [
   
__DIR__,
   
__FILE__,
];

Server::create('127.0.0.1', 9904)
    ->
watchFilesystemChanges($paths)
    ->
onRequest($handler)
    ->
setServerConfig([
       
'enable_static_handler' => true,
       
'http_parse_post' => true,
       
'worker_num' => 8,
       
'package_max_length' => 10 * 1024 * 1024
   
])
    ->
start()
    ->
logOutputToConsole();

For more information send a message to info at phpclasses dot org.