PHP code example of f4php / checkmate

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

    

f4php / checkmate example snippets



namespace F4;

class Config extends AbstractConfig
{
    // ...
    public string const CHECKMATE_ADAPTER_CLASS = \F4\Checkmate\Adapter\TwilioAdapter::class; // the default adapter
    public string const CHECKMATE_DEFAULT_CHANNEL = 'email'; // must be one of Adapter's supported channels, see below for channels supported by Twilio
    // ...
}


namespace F4;

use F4\Config\SensitiveParameter;

class Config extends AbstractConfig
{
    // ...
    #[SensitiveParameter]
    public string const TWILIO_ACCOUNT_SID = '...';
    #[SensitiveParameter]
    public string const TWILIO_AUTH_TOKEN = '...';
    #[SensitiveParameter]
    public string const TWILIO_VERIFY_SID = '...';
    // ...
}

use F4\Checkmate;

$checkmate = new Checkmate();

$checkmate->sendVerificationToken('[email protected]');
$booleanCheckResult = $checkmate->checkVerificationToken('[email protected]', '1234');



use F4\Checkmate;
use F4\Checkmate\Adapter\TwilioAdapter;
use Throwable;

$checkmate = new Checkmate()
  ->withAdapter(new TwilioAdapter()
    ->withOption('accountSid', '...')
    ->withOption('authToken', '...')
    ->withOption('verifySid', '...')
    ->withOption('defaultChannel', 'sms')
    ->on(Throwable::class, function(Throwable $exception) {
      // handle adapter exception
    })
  )
  ->on(Throwable::class, function(Throwable $exception) {
    // handle checkmate exception
  });

$checkmate->sendVerificationToken('+1234567890', 'whatsapp');
$booleanCheckResult = $checkmate->checkVerificationToken('+1234567890', '1234');