ofat / silex-jwt
This package is abandoned and no longer maintained.
No replacement package was suggested.
Library for work with JWT on Silex framework
v1.0.0
2016-11-24 15:28 UTC
Requires
- php: >=5.6.0
- firebase/php-jwt: ^4.0
This package is auto-updated.
Last update: 2022-04-10 16:07:07 UTC
README
Library for work with JWT on Silex framework.
You can generate and check JWT tokens, use middleware for auth checking.
Installation
composer require ofat\silex-jwt
Usage
- Register service provider:
<?php use Ofat\SilexJWT\JWTAuth; use Silex\Application; //Start our application $app = new Silex\Application(); //Register silex jwt service provider. Add jwt secret key $app->register(new JWTAuth(),[ 'jwt.secret' => 'test' ]); //Example of jwt generating $app->post('/login', function(Request $request) use ($app) { $userId = 1; $token = $app['jwt_auth']->generateToken($userId); return $app->json(['token' => $token]); }); //Example of checking json web token $app->get('/test', function(Request $request) use ($app) { return $app->json(['test' => true]); })->before(new JWTTokenCheck()); `