PHP code example of brenodouglas / laraveljwt

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

    

brenodouglas / laraveljwt example snippets


// file START ommited
    'providers' => [
        // other providers ommited
        \LaravelJwt\JwtProvider::class,
    ],
// file END ommited

Route::get('foo', ['middleware' => ['authjwt'], function()
{
    return 'Yes I can!';
}]);

$this->middleware('authjwt');

// file START ommited
    'aliases' => [
        // other aliases ommited
       'JWT' => \LaravelJwt\Facades\JwtAuthFacade::class
    ],
// file END ommited

Route::post("auth", function(\Illuminate\Http\Request $request) {
    return response()->json(['token'=> \JWT::authenticate($request)]);
});

Route::group(['middleware' => ['authjwt']], function($router) {
    $router->get('users', function() {
        return 'Yes, a can!';
    });
});
shell
php artisan vendor:publish