<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
chubbyphp / chubbyphp-swoole-request-handler example snippets
declare(strict_types=1);
namespace App;
use Chubbyphp\SwooleRequestHandler\OnRequest;
use Chubbyphp\SwooleRequestHandler\PsrRequestFactory;
use Chubbyphp\SwooleRequestHandler\SwooleResponseEmitter;
use Psr\Http\Server\RequestHandlerInterface;
use Slim\Psr7\Factory\ServerRequestFactory;
use Slim\Psr7\Factory\StreamFactory;
use Slim\Psr7\Factory\UploadedFileFactory;
use Swoole\Http\Server;
->on('request', new OnRequest(
new PsrRequestFactory(
new ServerRequestFactory(),
new StreamFactory(),
new UploadedFileFactory()
),
new SwooleResponseEmitter(),
$app
));
$http->start();
declare(strict_types=1);
namespace App;
use Blackfire\Client;
use Blackfire\Profile\Configuration;
use Chubbyphp\SwooleRequestHandler\Adapter\BlackfireOnRequestAdapter;
use Chubbyphp\SwooleRequestHandler\OnRequestInterface;
use Psr\Log\LoggerInterface;
/** @var OnRequestInterface $onRequest */
$onRequest = ...;
/** @var LoggerInterface $logger */
$logger = ...;
if (extension_loaded('blackfire')) {
$onRequest = new BlackfireOnRequestAdapter(
$onRequest,
new Client(),
new Configuration(), // optional, defaults to new Configuration()
$logger // optional, defaults to a NullLogger; receives Blackfire client errors
);
}
$http->on('request', $onRequest);
declare(strict_types=1);
namespace App;
use Chubbyphp\SwooleRequestHandler\Adapter\NewRelicOnRequestAdapter;
use Chubbyphp\SwooleRequestHandler\OnRequestInterface;
/** @var OnRequestInterface $onRequest */
$onRequest = ...;
if (extension_loaded('newrelic') && false !== $appname = ini_get('newrelic.appname')) {
$onRequest = new NewRelicOnRequestAdapter($onRequest, $appname);
}
$http->on('request', $onRequest);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.