1. Go to this page and download the library: Download vinelab/minion 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/ */
$loop = React\EventLoop\Factory::create();
$m = new Minion();
$m->run([], $loop);
public function get($args, $data)
use Vinelab\Minion\Provider;
class ChatProvider extends Provider
{
protected $prefix = 'chat.';
public function boot()
{
// will be registered to topic: chat.send
$this->register('send', 'sendMessage');
}
public function sendMessage($args, $data)
{
$message = $data->message;
// store message in the database
// tell everyone about it
$this->publish('message', compact('message'));
// response with the status
return true;
}
}
use Vinelab\Minion\Minion;
$m = new Minion;
$m->register('ChatProvider');
$m->run();
use Vinelab\Minion\Minion;
use Vinelab\Minion\Client;
// Get a minion instance
$m = new Minion;
$add = function ($x, $y) { return $x + $y; };
// Register a closure provider
$m->register(function (Client $client) use ($add) {
// register
$client->register('add', $add);
// subscribe
$client->subscribe('some.topic', function ($data) {
// do things with data
$data->key;
$data->other_key;
});
// publish
$client->publish('i.am.here', ['name' => 'mr.minion']);
});
src/
vendor/
start.php
composer.json
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.