Support the ongoing development of Laravel.io →
Queues Architecture Jobs

Hello! Im playing with Laravel 5 and trying to make a Queue asynchronously with beanstalkd or redis-server. After finish the job i want to return a popup alert to user which triggered the queue and tell him that alls done.

I installed a fresh laravel 5 with all`s from this tutorial
I created in routes.php a home route that start the queue like:

Route::get('/', function() {

	Queue::push(function($job)
	{
		Log::info('Queue is staring');

		$job->delete();
	});

});

Now, i know that to make that callback i need to use socket.io (that i already installed with node, nodejs).

Someone could help me with a socket.io or something tutorial regarding how cand i make that callback to tell user x that job y is done?

I`ll realy apreciate, cause i never playd with socket or node,

Thanks

Last updated 3 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 10 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!

PHPverse

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.

© 2025 Laravel.io - All rights reserved.