worksome / laravel-onfido
A Laravel wrapper for the Onfido PHP client
Installs: 290 906
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 7
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- illuminate/support: ^10.0 || ^11.0
- onfido/onfido-php: ^7.5
Requires (Dev)
- orchestra/testbench: ^8.0 || ^9.0
- pestphp/pest: ^2.33
- worksome/coding-style: ^2.11
README
A Laravel wrapper for the Onfido PHP API Client.
Installation
Install using composer:
composer require worksome/laravel-onfido
Publish the configuration file with the following command:
php artisan vendor:publish --provider "Worksome\Onfido\OnfidoServiceProvider"
Configuration
Remember to add your Onfido API key to your .env
file.
ONFIDO_API_KEY=api_sandbox.ABC...
Usage
I would always encourage anyone to use the official PHP package as reference, and this is simply a Laravel wrapper. However, I will provide an example on how to create an applicant.
Remember to import the Onfido facade, by adding use Worksome\Onfido\Facades\Onfido;
at the top of your file.
To create an applicant and send a check:
use Onfido\Model\ApplicantBuilder; use Onfido\Model\CheckBuilder; use Worksome\Onfido\Facades\Onfido; $applicant = Onfido::createApplicant(new ApplicantBuilder([ 'first_name' => 'John', 'last_name' => 'Doe', 'email' => 'johndoe@example.org', ])); $onfidoCheck = Onfido::createCheck(new CheckBuilder([ 'applicant_id' => $applicant['id'], 'report_names' => ['right_to_work'], 'applicant_provides_data' => true, ]));
The above is all that is required to create an applicant and send the applicant a right to work check via Onfido.
You can then consult the results of the applicant or check:
/** @var \Onfido\Model\ApplicantResponse $applicant */ $applicant->getId(); /** @var \Onfido\Model\CheckResponse $onfidoCheck */ $onfidoCheck->getId(); // The responses can also be accessed as an arrayable. $applicant['id']; $onfidoCheck['id']; $onfidoCheck['status']; $onfidoCheck['form_uri'];
To see all possible return data check the official PHP package documentation.