承接 f4php/checkmate 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

f4php/checkmate

最新稳定版本:v0.1.6

Composer 安装命令:

composer require f4php/checkmate

包简介

Checkmate is a user verification package for F4, a lightweight web development framework

README 文档

README

Checkmate is a user verification package for F4, a lighweight web development framework.

Checkmate uses Twilio Verify API by default.

Checkmate implements a very simple F4\Checkmate\UserVerificationServiceInterface, so you can create your own drop-in replacement if needed.

Quick Start

$ composer require f4php/checkmate

SDK Architecture

Checkmate uses Guzzle to interact with external APIs to send and verify one-time authentication tokens using various channels.

This SDK supports F4\Checkmate\Adapter\AdapterInterface, which allows you to add seamless support for virtually any external provider.

The following constants MUST be defined in an F4 environment config class:

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
    // ...
}

Additionally, Twilio integration requires that the following constants MUST be defined in an F4 environment config class:

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 = '...';
    // ...
}

TwilioAdapter supports the following channels: auto, call, email, sms, sna, whatsapp.

Simple example

use F4\Checkmate;

$checkmate = new Checkmate();

$checkmate->sendVerificationToken('email@address.com');
$booleanCheckResult = $checkmate->checkVerificationToken('email@address.com', '1234');

Advanced example

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');

统计信息

  • 总下载量: 20
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-02