add a http api
This commit is contained in:
parent
be92a0a73e
commit
8a49a7c21b
28
api.php
Normal file
28
api.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
use Workerman\Worker;
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// #### http worker ####
|
||||
$http_worker = new Worker('http://0.0.0.0:2345');
|
||||
|
||||
// 4 processes
|
||||
$http_worker->count = 4;
|
||||
|
||||
// Emitted when data received
|
||||
$http_worker->onMessage = function ($connection, $request) {
|
||||
//$request->get();
|
||||
//$request->post();
|
||||
//$request->header();
|
||||
//$request->cookie();
|
||||
//$request->session();
|
||||
//$request->uri();
|
||||
//$request->path();
|
||||
//$request->method();
|
||||
|
||||
// Send data to client
|
||||
$connection->send("Hello World");
|
||||
};
|
||||
|
||||
// Run all workers
|
||||
Worker::runAll();
|
||||
Loading…
x
Reference in New Issue
Block a user