PHP code example of roundly-consulting / passkeys-for-laravel

1. Go to this page and download the library: Download roundly-consulting/passkeys-for-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/ */

    

roundly-consulting / passkeys-for-laravel example snippets


use RoundlyConsulting\Passkeys\Concerns\InteractsWithPasskeys;
use RoundlyConsulting\Passkeys\Contracts\HasPasskeys;

final class User extends Authenticatable implements HasPasskeys
{
    use InteractsWithPasskeys;
}

// in a migration
Schema::table('users', fn (Blueprint $table) => $table->passkeyUserHandle());

use RoundlyConsulting\Passkeys\DataTransferObjects\RegistrationResponseData;
use RoundlyConsulting\Passkeys\Facades\Passkeys;

return response()->json(Passkeys::for($user)->registrationOptions());

$passkey = Passkeys::for($user)->register(
    RegistrationResponseData::fromArray($request->all()),
    name: 'MacBook Touch ID',
);

use RoundlyConsulting\Passkeys\DataTransferObjects\AuthenticationResponseData;

return response()->json(Passkeys::authenticationOptions());

$passkey = Passkeys::authenticate(AuthenticationResponseData::fromArray($request->all()));

Auth::login($passkey->authenticatable);
bash
composer vendor:publish --tag="passkeys-migrations"
php artisan migrate