1. Go to this page and download the library: Download iankibet/redis-sub 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/ */
namespace App\Jobs;
use Illuminate\Contracts\Queue\ShouldQueue;
class ProcessMemberMessage implements ShouldQueue
{
protected $message;
public function __construct($message)
{
$this->message = $message;
}
public function handle()
{
logger()->info("Processed job message: {$this->message}");
}
}
namespace App\Events;
use Illuminate\Foundation\Events\Dispatchable;
class NotificationReceived
{
use Dispatchable;
public $message;
public function __construct($message)
{
$this->message = $message;
}
}
namespace App\Listeners;
class MemberListener
{
public function __invoke($message)
{
logger()->info("Handled message with callable: {$message}");
}
}
bash
php artisan redis:subscribe
text
[2024-11-24 15:30:15] Dispatched job: App\Jobs\ProcessMemberMessage for channel: members
[2024-11-24 15:30:15] Called handler: App\Listeners\MemberListener for channel: members
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.