@@ -4,24 +4,32 @@ PHP-JWT
4
4
A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should
5
5
conform to the [ current spec] ( http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06 )
6
6
7
+ Installation
8
+ ------------
9
+
10
+ Use composer to manage your dependencies and download PHP-JWT:
11
+
12
+ ``` bash
13
+ php composer require firebase/php-jwt
14
+ ```
15
+
7
16
Example
8
17
-------
9
18
``` php
10
19
<?php
11
- include_once 'Authentication/JWT.php';
12
20
13
- $key = "example_key";
14
- $token = array(
21
+ $key = "example_key";
22
+ $token = array(
15
23
"iss" => "http://example.org",
16
24
"aud" => "http://example.com",
17
25
"iat" => 1356999524,
18
26
"nbf" => 1357000000
19
- );
27
+ );
20
28
21
- $jwt = JWT::encode($token, $key);
22
- $decoded = JWT::decode($jwt, $key);
29
+ $jwt = JWT::encode($token, $key);
30
+ $decoded = JWT::decode($jwt, $key);
23
31
24
- print_r($decoded);
32
+ print_r($decoded);
25
33
?>
26
34
```
27
35
@@ -30,12 +38,12 @@ Tests
30
38
Run the tests using phpunit:
31
39
32
40
``` bash
33
- $ pear install PHPUnit
34
- $ phpunit tests/
35
- PHPUnit 3.7.10 by Sebastian Bergmann.
36
- .....
37
- Time: 0 seconds, Memory: 2.50Mb
38
- OK (5 tests, 5 assertions)
41
+ $ pear install PHPUnit
42
+ $ phpunit --configuration phpunit.xml.dist
43
+ PHPUnit 3.7.10 by Sebastian Bergmann.
44
+ .....
45
+ Time: 0 seconds, Memory: 2.50Mb
46
+ OK (5 tests, 5 assertions)
39
47
```
40
48
41
49
License
0 commit comments