1. Go to this page and download the library: Download maniaba/codeigniter4-sse 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\Sse;
use Maniaba\CodeIgniterSse\Contracts\ChannelAuthorizerInterface;
final class ChannelAuthorizer implements ChannelAuthorizerInterface
{
public function authorize(?object $user, string $channel): bool
{
if (str_starts_with($channel, 'public.')) {
return true;
}
if (
$user !== null
&& preg_match('/^users\.(\d+)$/', $channel, $matches) === 1
) {
return (string) $user->id === $matches[1];
}
return false;
}
}
declare(strict_types=1);
namespace Config;
use Maniaba\CodeIgniterSse\Config\Sse as BaseSse;
final class Sse extends BaseSse
{
public string $channelPrefix = 'myapp:sse:';
public int $heartbeatInterval = 15;
public int $maxConnectionSeconds = 300;
public int $maxChannelsPerConnection = 20;
}
public string $broker = 'mercure';
bash
redis-cli ping
php spark sse:health-check
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.