PHP code example of mostbyte / auth

1. Go to this page and download the library: Download mostbyte/auth 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/ */

    

mostbyte / auth example snippets


use Mostbyte\Auth\Middleware\IdentityAuth;

Route::middleware(IdentityAuth::class)->get('/foo', function () {
    return 'bar';
});

use Mostbyte\Auth\Middleware\IdentityAuth;

Route::middleware(IdentityAuth::using('no-domain'))->get('/foo', function () {
    return 'bar';
});

->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'identity' => \Mostbyte\Auth\Middleware\IdentityAuth::class,
    ]);
})

Route::middleware('identity')->get('/foo', function () {
    return 'bar';
});

// Get authenticated user
$user = auth()->user();

// Access relationships
$company = auth()->user()->company;
$role = auth()->user()->role;

// Get token
$token = auth()->user()->getToken();
bash
php artisan vendor:publish --provider="Mostbyte\Auth\AuthServiceProvider"