Skip to content

This project is just a simple JWT class to add to your project and can be configured using contants.

License

Notifications You must be signed in to change notification settings

GuilhermeTome/jwt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jwt class

Scrutinizer Code Quality GitHub last commit GitHub repository size Build Status Code Intelligence Status

This project is just a simple JWT class to add to your project and can be configured using contants.

Summary

Prerequisites

  • PHP >= 7.2
  • Composer

Installing

You can clone the project with this command:

  • Clone repository:
git clone https://github.com/GuilhermeTome/jwt
  • Install in your project:
composer require guilhermetome/jwt

How to use

  • Only follow the docs.

Declare the jwt key

  • In you application you need to create a const like this:
<?php

// the key of the application
define('JWT_SECRET', 'mysecret');

// the hash of the jwt
define('JWT_HASH', 'sha256');

// the alg to put in header
define('JWT_ALG', 'HS256');

Generate the jwt key

  • @param array
  • @return string
<?php

use GuilhermeTome\Jwt;

echo Jwt::encode([
    'user' => 'Guilherme',
    'email' => '[email protected]',
    'pass' => 'MyPassword'
]);

Decode the jwt key

  • @param string
  • @return array|false
<?php

use GuilhermeTome\Jwt;

echo Jwt::decode($key);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

License

This project is licensed under the MIT Licence - see the MIT Licence for more details

About

This project is just a simple JWT class to add to your project and can be configured using contants.

Topics

Resources

License

Stars

Watchers

Forks

Languages