1. Go to this page and download the library: Download ssofy/laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ssofy / laravel example snippets
Route::middleware(['web', 'nine:redirect'])->group(function () {
Route::get('/dashboard', function () {
$user = auth()->user(); // Nine\Laravel\User: id (= sub), email, name, … from the ID token
return view('dashboard', compact('user'));
});
});
// Links
route('nine.login', ['return_to' => '/dashboard']); // add 'screen' => 'signup' for the sign-up form
route('nine.logout');
Route::middleware(['nine', 'nine.scope:orders:read'])->get('/api/orders', function () {
$sub = auth()->id(); // 9in user id
$claims = auth('nine')->claims(); // access-token claims: client_id, scope, aud, …
});
use Nine\Laravel\Events\UserCreated;
Event::listen(UserCreated::class, function (UserCreated $event) {
$user = $event->user(); // the 9in user (Management API shape: snake_case, ISO 8601 times)
// $event->id() is stable across retries: use it to ignore duplicates
});