PHP code example of kayrules / lumen-passport-mongodb
1. Go to this page and download the library: Download kayrules/lumen-passport-mongodb 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/ */
kayrules / lumen-passport-mongodb example snippets
// Enable Facades
$app->withFacades();
// Register jenssegers/mongodb service provider before `$app->withEloquent()`
$app->register(Jenssegers\Mongodb\MongodbServiceProvider::class);
// Enable Eloquent
$app->withEloquent();
// Enable auth middleware (shipped with Lumen)
$app->routeMiddleware([
'auth' => App\Http\Middleware\Authenticate::class,
]);
// Finally register service providers
$app->register(Kayrules\LumenPassport\PassportServiceProvider::class);
use MoeenBasra\LaravelPassportMongoDB\HasApiTokens;
class User extends Model implements AuthenticatableContract, AuthorizableContract
{
use HasApiTokens, Authenticatable, Authorizable;
/* rest of the model */
}
use Kayrules\LumenPassport\LumenPassport;
// Somewhere in your application service provider or bootstrap process
LumenPassport::allowMultipleTokens();
// Second parameter is the client Id
LumenPassport::tokensExpireIn(Carbon::now()->addYears(50), 2);
artisan passport:purge
bootstrap/app.php
bash
# Create new tables for Passport
php artisan migrate
# Install encryption keys and other necessary stuff for Passport
php artisan passport:install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.