Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/portier/portier-php
Portier client for PHP
https://github.com/portier/portier-php
Last synced: 3 months ago
JSON representation
Portier client for PHP
- Host: GitHub
- URL: https://github.com/portier/portier-php
- Owner: portier
- License: mit
- Created: 2016-11-04T13:30:50.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2023-12-01T10:55:18.000Z (12 months ago)
- Last Synced: 2024-05-17T06:49:41.755Z (6 months ago)
- Language: PHP
- Size: 57.6 KB
- Stars: 7
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# portier-php
A [Portier] client library for PHP.
[portier]: https://portier.github.io/
### Example
```php
addRoutingMiddleware();
$app->addErrorMiddleware(true, true, true);$redis = new Redis();
$redis->pconnect('127.0.0.1', 6379);$portier = new \Portier\Client\Client(
new \Portier\Client\RedisStore($redis),
'http://localhost:8000/verify'
);$app->get('/', function($req, $res) {
$res = $res
->withStatus(200)
->withHeader('Content-Type', 'text/html; charset=utf-8');$res->getBody()->write(
<<Enter your email address:
Login
EOF
);return $res;
});$app->post('/auth', function($req, $res) use ($portier) {
$authUrl = $portier->authenticate($req->getParsedBody()['email']);return $res
->withStatus(303)
->withHeader('Location', $authUrl);
});$app->post('/verify', function($req, $res) use ($portier) {
$email = $portier->verify($req->getParsedBody()['id_token']);$res = $res
->withStatus(200)
->withHeader('Content-Type', 'text/html; charset=utf-8');$res->getBody()->write(
<<Verified email address ${email}!
EOF
);return $res;
});$app->run();
```