PHPPM\Debug\BufferingLogger::create PHP Method

create() public static method

public static create ( ) : BufferingLogger | Symfony\Component\Debug\BufferingLogger
return BufferingLogger | Symfony\Component\Debug\BufferingLogger Check if we are using symfony/debug >= 2.8. In symfony/debug <= 2.7, \Symfony\Component\Debug\BufferingLogger isn't available. Laravel 5.1 depends on symfony/debug 2.7.*, so to support Laravel 5.1 we supply a custom BufferingLogger when Symfony's BufferingLogger isn't available.
    public static function create()
    {
        if (class_exists('\\Symfony\\Component\\Debug\\BufferingLogger')) {
            return new \Symfony\Component\Debug\BufferingLogger();
        }
        return new static();
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Connects to ProcessManager, master process.
  */
 public function run()
 {
     $this->loop = \React\EventLoop\Factory::create();
     $this->errorLogger = BufferingLogger::create();
     ErrorHandler::register(new ErrorHandler($this->errorLogger));
     $client = stream_socket_client($this->config['controllerHost']);
     $this->controller = new \React\Socket\Connection($client, $this->loop);
     $pcntl = new \MKraemer\ReactPCNTL\PCNTL($this->loop);
     $pcntl->on(SIGTERM, [$this, 'shutdown']);
     $pcntl->on(SIGINT, [$this, 'shutdown']);
     register_shutdown_function([$this, 'shutdown']);
     $this->bindProcessMessage($this->controller);
     $this->controller->on('close', \Closure::bind(function () {
         $this->shutdown();
     }, $this));
     $this->server = new React\Server($this->loop);
     //our version for now, because of unix socket support
     $http = new HttpServer($this->server);
     $http->on('request', array($this, 'onRequest'));
     //port is only used for tcp connection. If unix socket, 'host' contains the socket path
     $port = $this->config['port'];
     $host = $this->config['host'];
     while (true) {
         try {
             $this->server->listen($port, $host);
             break;
         } catch (\React\Socket\ConnectionException $e) {
             usleep(500);
         }
     }
     $this->sendMessage($this->controller, 'register', ['pid' => getmypid(), 'port' => $port]);
     $this->loop->run();
 }