onfido/onfido-php
Composer 安装命令:
composer require onfido/onfido-php
包简介
The Onfido Public API (v3.6)
README 文档
README
The official PHP library for integrating with the Onfido API.
Documentation can be found at https://documentation.onfido.com.
This version uses Onfido API v3.6. Refer to our API versioning guide for details of which client library versions use which versions of the API.
Installation & Usage
Requirements
PHP 8.1 and later.
Installation
Composer
To install the bindings via Composer, add the following to composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/onfido/onfido-php.git"
}
],
"require": {
"onfido/onfido-php": "*@dev"
}
}
Then run composer install
Manual Installation
Download the files and include autoload.php:
<?php require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');
Getting Started
Please follow the installation instructions and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); $configuration = Onfido\Configuration::getDefaultConfiguration(); $configuration->setApiToken($_ENV['ONFIDO_API_TOKEN']); $configuration->setRegion(Onfido\Region::EU); // Supports `Region::EU`, `Region::US`, and `Region::CA` $onfidoApi = new Onfido\Api\DefaultApi( new \GuzzleHttp\Client([ 'timeout' => 30, 'connect_timeout' => 30, 'read_timeout' => 30 ]), $configuration);
You can also authenticate using OAuth2 client credentials instead of an API token:
<?php require_once(__DIR__ . '/vendor/autoload.php'); $configuration = Onfido\Configuration::getDefaultConfiguration(); $configuration->setOAuthCredentials($_ENV['ONFIDO_OAUTH_CLIENT_ID'], $_ENV['ONFIDO_OAUTH_CLIENT_SECRET']); $configuration->setRegion(Onfido\Region::EU); // Supports `Region::EU`, `Region::US`, and `Region::CA` $onfidoApi = new Onfido\Api\DefaultApi( new \GuzzleHttp\Client([ 'timeout' => 30, 'connect_timeout' => 30, 'read_timeout' => 30 ]), $configuration);
The client will automatically exchange credentials for an access token and refresh it when it expires.
Making a call to the API
try { $applicant = $onfidoApi->createApplicant( new Onfido\Model\ApplicantBuilder( [ 'first_name' => 'First', 'last_name' => 'Last' ]) ); // To access the information use the getter for the desired property on the object, for example: $applicant->getFirstName(); // ... } catch (Onfido\ApiException $ex) { // Handle API exception echo 'Caught exception: ', $ex->getMessage(), "\n"; }
Webhook event verification
Webhook events payload needs to be verified before it can be accessed. The library allows easy decoding of the payload and verification of its signature before returning it as an object for user convenience:
try { $verifier = new Onfido\WebhookEventVerifier(getenv('ONFIDO_WEBHOOK_SECRET_TOKEN')); $signature = 'a0...760e'; $event = $verifier->readPayload('{"payload":{"r...3"}}', $signature); } catch (Onfido\OnfidoInvalidSignatureError $ex) { // Invalid webhook signature }
Recommendations
Do not use square bracket syntax
Except for accessing Task object's outputs, avoid using the square bracket syntax (i.e. []) to access undefined properties to prevent breaking changes when these fields appear.
Contributing
This library is automatically generated using OpenAPI Generator (version: 7.16.0); therefore, all contributions (except test files) should target the Onfido OpenAPI specification repository instead of this repository. Please follow the contribution guidelines provided in the OpenAPI specification repository.
For contributions to the tests instead, please follow the steps below:
- Fork the repository
- Create your feature branch (
git checkout -b my-new-feature) - Make your changes
- Commit your changes (
git commit -am 'Add detailed description of the feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Versioning policy
Versioning helps manage changes and ensures compatibility across different versions of the library.
Semantic Versioning policy is used for library versioning, following the guidelines and limitations outlined below:
- MAJOR versions (x.0.0) may:
- target a new API version
- include non-backward compatible change
- MINOR versions (0.x.0) may:
- add a new functionality, non-mandatory parameter or property
- deprecate an old functionality
- include non-backward compatible change to a functionality which is:
- labelled as alpha or beta
- completely broken and not usable
- PATCH version (0.0.x) will:
- fix a bug
- include backward compatible changes only
More documentation
Additional documentation and code examples can be found at https://documentation.onfido.com.
Support
Should you encounter any technical issues during integration, please contact Onfido's Customer Support team via the Customer Experience Portal which also includes support documentation.
onfido/onfido-php 适用场景与选型建议
onfido/onfido-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 195.94k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2024 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「rest」 「api」 「sdk」 「openapi」 「openapitools」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 onfido/onfido-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 onfido/onfido-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 onfido/onfido-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
Alfabank REST API integration
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
BlockCypher's PHP SDK for REST API
Helper classes for creating cookie headers
统计信息
- 总下载量: 195.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-28