PHP code example of siam / easyswoole-http-monitor

1. Go to this page and download the library: Download siam/easyswoole-http-monitor 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/ */

    

siam / easyswoole-http-monitor example snippets



use Siam\HttpMonitor\Config;
use Siam\HttpMonitor\Monitor;

// 主页面
$routeCollector->get('/siam/http-monitor', function (Request $request, Response $response) {
    $monitor = Monitor::getInstance();
    $html = $monitor->listView();
    $response->withHeader('Content-type','text/html;charset=utf-8');
    $response->write("$html");//获取到路由匹配的id
    return false;//不再往下请求,结束此次响应
});

// 获取历史列表
$routeCollector->addRoute(['POST', 'GET'], '/siam/http-monitor/get_list', function (Request $request, Response $response) {
    $response->withHeader('Content-type','text/html;charset=utf-8');
    $response->write(Monitor::getInstance()->getList());//获取到路由匹配的id
    return false;//不再往下请求,结束此次响应
});

// 复发请求
$routeCollector->addRoute(['POST'], '/siam/http-monitor/resend', function (Request $request, Response $response) {
    $content = $request->getBody()->__toString();
    $content = json_decode($content, true);
    $response->write(Monitor::getInstance()->resend($content['id']));
    return false;//不再往下请求,结束此次响应
});