1. Go to this page and download the library: Download mehdibo/paseto-bundle 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/ */
// For building local tokens
$localBuilder = new \Mehdibo\Bundle\PasetoBundle\Services\LocalPasetoBuilder();
// For building public tokens
$publicBuilder = new \Mehdibo\Bundle\PasetoBundle\Services\PublicPasetoBuilder();
namespace App\Controller;
use Mehdibo\Bundle\PasetoBundle\Services\LocalPasetoBuilder;
use Mehdibo\Bundle\PasetoBundle\Services\PublicPasetoBuilder;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class TokensController extends AbstractController
{
#[Route('/public', name: 'public')]
public function public(PublicPasetoBuilder $builder): Response
{
$builder->setIssuedAt()->setClaims(['custom' => 'claim']);
return new Response($builder->toString());
}
#[Route('/local', name: 'local')]
public function local(LocalPasetoBuilder $builder): Response
{
$builder->setIssuedAt()->setClaims(['custom' => 'claim']);
return new Response($builder->toString());
}
}
// For parsing local tokens
$localParser = new \Mehdibo\Bundle\PasetoBundle\Services\LocalPasetoParser();
// For parsing public tokens
$publicParser = new \Mehdibo\Bundle\PasetoBundle\Services\PublicPasetoParser();
namespace App\Controller;
use Mehdibo\Bundle\PasetoBundle\Services\LocalPasetoParser;
use Mehdibo\Bundle\PasetoBundle\Services\PublicPasetoParser;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
class TokensController extends AbstractController
{
#[Route('/public/decode', name: 'public_decode')]
public function publicDecode(PublicPasetoParser $parser): JsonResponse
{
$token = $parser->parse("PUBLIC_TOKEN_HERE");
return new JsonResponse($token->getClaims());
}
#[Route('/local/decode', name: 'local_decode')]
public function localDecode(LocalPasetoParser $parser): JsonResponse
{
$token = $parser->parse("LOCAL_TOKEN_HERE");
return new JsonResponse($token->getClaims());
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.