Support the ongoing development of Laravel.io →
Queues Architecture Jobs
Last updated 2 years ago.
0

Try use Elephant

This might also help you. http://stackoverflow.com/questions/6398887/using-php-with-socket-io

So you should end up with something like this, you want to emit after your queue job is done using Laravel's Events or something.

Server side, Node.js

var server     = require('http').createServer(),
      io         = require('socket.io')(server);

io.on('connection', function (socket) {
   socket.on('broadcast', function (message) {
        // {foo: 'bar'}
        // You can then emit message back to subscriber
    });
};

server.listen(1337);

Client, PHP

use ElephantIO\Client;
use ElephantIO\Engine\SocketIO\Version1X;
require __DIR__ . '/../../../../vendor/autoload.php';

$client = new Client(new Version1X('http://localhost:1337'));
$client->initialize();
$client->emit('broadcast', ['foo' => 'bar']);
$client->close();

Hope it helps!

Last updated 9 years ago.
0

Hello @awsp Thanks for your code sharing. I read some tutorials and documentation from socket.io and redis and in the end I understood how it works.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

oriceon oriceon Joined 28 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.