I use predis and i want subscribe to channel in PHP and wait 30 seconds. If not receive any messages at channel, return json response. Or if messages in channel exists, return response too and exit.
For example i want, that my Redis::subscribe return $message and i can return response.
I have a some code in Controller in Laravel:
Redis::subscribe(['PushAuthChanel'], function($message) {
echo $message; // Nothing happens
return response()->json($c, 200); // Nothing happens
//return $message; // Nothing happens too
});
And why Redis::subscribe can not return $message? But it well return exit code like this:
Redis::subscribe(['PushAuthChanel'], function($message) {
return exit(0); //will work
dd($message); //will work fine
});