for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Mercure;
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use Lcobucci\JWT\Signer\Key;
use Symfony\Component\HttpFoundation\Cookie;
final class CookieGenerator
{
private $secret;
public function __construct(string $secret)
$this->secret = $secret;
}
public function generate(): Cookie
$token = (new Builder())
->withClaim('mercure', ['subscribe' => ['*']])
->getToken(new Sha256(), new Key($this->secret));
return Cookie::create('mercureAuthorization', $token, 0, '/.well-known/mercure');