PHP code example of chubbyphp / chubbyphp-workerman-request-handler

1. Go to this page and download the library: Download chubbyphp/chubbyphp-workerman-request-handler 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/ */

    

chubbyphp / chubbyphp-workerman-request-handler example snippets




declare(strict_types=1);

namespace App;

use Chubbyphp\WorkermanRequestHandler\OnMessage;
use Chubbyphp\WorkermanRequestHandler\PsrRequestFactory;
use Chubbyphp\WorkermanRequestHandler\WorkermanResponseEmitter;
use Psr\Http\Server\RequestHandlerInterface;
use Some\Psr17\Factory\ServerRequestFactory;
use Some\Psr17\Factory\StreamFactory;
use Some\Psr17\Factory\UploadedFileFactory;
use Workerman\Worker;

$loader = nseEmitter(),
    $app
);

Worker::runAll();



declare(strict_types=1);

namespace App;

use Blackfire\Client;
use Chubbyphp\WorkermanRequestHandler\Adapter\BlackfireOnMessageAdapter;
use Chubbyphp\WorkermanRequestHandler\OnMessage;

/** @var OnMessage $onMessage */
$onMessage = ...;

if (extension_loaded('blackfire') {
    $onMessage = new BlackfireOnMessageAdapter($onMessage, new Client());
}

$http->onMessage = $onMessage;



declare(strict_types=1);

namespace App;

use Chubbyphp\WorkermanRequestHandler\Adapter\NewRelicOnMessageAdapter;
use Chubbyphp\WorkermanRequestHandler\OnMessage;

/** @var OnMessage $onMessage */
$onMessage = ...;

if (extension_loaded('newrelic') && false !== $name = ini_get('newrelic.appname')) {
    $onMessage = new NewRelicOnMessageAdapter($onMessage, $name);
}

$http->onMessage = $onMessage;