2017 © Pedro PelĂĄez
 

library client

Portier client for PHP

image

portier/client

Portier client for PHP

  • Friday, January 5, 2018
  • by portier
  • Repository
  • 4 Watchers
  • 6 Stars
  • 3,256 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 7 Versions
  • 38 % Grown

The README.md

portier-php

A Portier client library for PHP., (*1)

Example

<?php

require 'vendor/autoload.php';

$app = \Slim\Factory\AppFactory::create();
$app->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(
<<<EOF
        <p>Enter your email address:</p>
        <form method="post" action="/auth">
            <input name="email" type="email">
            <button type="submit">Login</button>
        </form>
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(
<<<EOF
        <p>Verified email address ${email}!</p>
EOF
    );

    return $res;
});

$app->run();

The Versions

05/01 2018
05/01 2018

dev-featNormalize

dev-featNormalize

Portier client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stéphan Kochen

17/02 2017
17/02 2017

dev-fixCacheControl

dev-fixCacheControl

Portier client for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stéphan Kochen

04/11 2016