PHP code example of chh / einhorn

1. Go to this page and download the library: Download chh/einhorn 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/ */

    

chh / einhorn example snippets




use Einhorn\Worker;

$client = Worker::client();



use Einhorn\Worker;

$client = Worker::client(Worker::DISCOVER_FD);
$client->ack();



user Einhorn\Worker;

$client = Worker::client();

$client->command(array("command" => "state"));

$state = $client->recv();



use Einhorn\Worker;

$client = Worker::client();
$client->ack();



use Einhorn\Worker;

# Returns the first socket found in `EINHORN_FDS` environment variable
$socket = Worker::socket();

# Returns all sockets bound via the -b flag
$sockets = Worker::sockets();

# When the FD number is passed by other means:
$socket = Worker::socket($fd);