1. Go to this page and download the library: Download danog/ipc 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/ */
danog / ipc example snippets
declare(strict_types=1);
ket;
use function Amp\async;
use function Amp\Ipc\listen;
$clientHandler = function (ChannelledSocket $socket) {
echo "Accepted connection".PHP_EOL;
while ($payload = $socket->receive()) {
echo "Received $payload".PHP_EOL;
if ($payload === 'ping') {
$socket->send('pong');
$socket->disconnect();
}
}
echo "Closed connection".PHP_EOL."==========".PHP_EOL;
};
$server = listen(sys_get_temp_dir().'/test');
while ($socket = $server->accept()) {
async($clientHandler, $socket);
}
declare(strict_types=1);
ket;
use function Amp\async;
use function Amp\Ipc\connect;
$clientHandler = function (ChannelledSocket $socket) {
echo "Created connection.".PHP_EOL;
while ($payload = $socket->receive()) {
echo "Received $payload".PHP_EOL;
}
echo "Closed connection".PHP_EOL;
};
$channel = connect(sys_get_temp_dir().'/test');
$thread = async($clientHandler, $channel);
$channel->send('ping');
$thread->await();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.