PHP code example of atatus / swoole-atatus
1. Go to this page and download the library: Download atatus/swoole-atatus 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/ */
atatus / swoole-atatus example snippets
$page = <<<HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example page</title>
</head>
<body>
Served by Swoole server
</body>
</html>
HTML;
$server = new \Swoole\Http\Server('127.0.0.1', 8080);
$server->on('request', function ($request, $response) use ($page) {
// PHP processing within request boundary...
usleep(1000 * rand(100, 300));
// Send response
$response->end($page);
// PHP processing outside of request boundary...
usleep(1000 * rand(50, 150));
});
// Application performnce monitoring (APM)
$apm = new Atatus\Swoole\AtatusApm(new Atatus\Swoole\AtatusApm\TransactionFactory());
$apm->instrument($server);
unset($apm);
$server->start();