PHP code example of cegrent / auth0-laravel
1. Go to this page and download the library: Download cegrent/auth0-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/ */
cegrent / auth0-laravel example snippets
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Cache;
// ...
public function register()
{
// ...
$this->app->bind(
'\Auth0\SDK\Helpers\Cache\CacheHandler',
function() {
static $cacheWrapper = null;
if ($cacheWrapper === null) {
$cache = Cache::store();
$cacheWrapper = new LaravelCacheWrapper($cache);
}
return $cacheWrapper;
});
}
// get user
auth('auth0')->user();
// check if logged in
auth('auth0')->check();
// protect routes via middleware use
Route::group(['middleware' => 'auth:auth0'], function () {});