PHP code example of pioneer-dynamics / laravel-passkey
1. Go to this page and download the library: Download pioneer-dynamics/laravel-passkey 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/ */
pioneer-dynamics / laravel-passkey example snippets
namespace App\Models;
use PioneerDynamics\LaravelPasskey\Traits\HassPasskeys;
use PioneerDynamics\LaravelPasskey\Contracts\PasskeyUser;
// ...
use Illuminate\Foundation\Auth\User as Authenticatable;
// ...
class User extends Authenticatable implements PasskeyUser
{
// ...
use HasPasskeys;
// ...
/**
* If you wish to not use `HasPassKeys` trait, you must eager load `passkeys`
* attribute like this:
*
*/
// protected $with = ['passkeys'];
/**
* In addition to some helper methods, the below methods are defined
* in the `HasPasskeys` trait. Override them here if needed.
*
* Below are the default definitions in `HasPasskeys`
*/
// public function getUsername()
// {
// // The username of the user (Shown by the browser passkey interface)
// return $this->email;
// }
//
// public function getUserId()
// {
// // The ID of the user
// return $this->id;
// }
//
// public function getDisplayName()
// {
// // The display name of the user
// return $this->name;
// }
//
// protected function generateUserImageFrom()
// {
// // return the attribute that holds the path to the user image (preferably public url)
// return 'profile_photo_url';
// }
// ...
}
namespace App\Providers;
// ...
use Inertia\Inertia;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Laravel\Fortify\Fortify;
// ...
class FortifyServiceProvider extends ServiceProvider
{
// ...
/**
* Bootstrap any application services.
*/
public function boot(): void
{
// ...
Fortify::loginView(function () {
return Inertia::render('Auth/LoginWithPasskey', [
'canResetPassword' => Route::has('password.request'),
'status' => session('status'),
]);
});
// ...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.