toString

Learn how to serialize the token to a string.

This method serializes the token to its string representation. The result is the encoded JSON Web Token (JWT).

Signature

This method has the following signature:

public function toString(): string

This method returns the serialized JWT string.

Example

Here is a basic example of how to use this method:

<?phpuse Croct\Plug\Croct;
$croct = Croct::fromDotenv();$token = $croct->getUserToken();
$serialized = $token->toString();