Laravel
Validate documents with AI in Laravel
The PHP SDK ships a ServiceProvider and facade: Constaia::analyze() in your controller.
Install
composer require constaia/constaia-php
The safe pattern
The browser or app never sees your secret key. The file goes to your server, your server calls Constaia and returns the verdict.
app/Http/Controllers/VerifyController.php
<?php
namespace App\Http\Controllers;
use Constaia\Laravel\Facades\Constaia;
use Illuminate\Http\Request;
class VerifyController extends Controller
{
public function __invoke(Request $request)
{
$request->validate(['file' => ['required', 'file', 'max:20480']]);
// Pass the UploadedFile: the SDK keeps the original file name
$analysis = Constaia::analyze($request->file('file'), [
'expect' => 'es_dni',
'checks' => ['not_expired' => true],
'storage' => 'none',
]);
return response()->json([
'status' => $analysis->verdictStatus(),
'valid' => $analysis->isValid(),
]);
}
}One call. An answer you can act on.
- 01
Send the document and what you expect
Photo, screenshot or PDF. Set the expected type and the rules: not expired, under 6 months old, in this person's name.
- 02
We read, classify and check
OCR, AI classification and deterministic validators: PDF417 barcodes, MRZ, ABA routing numbers, dates and totals.
- 03
Get the verdict and delete the file
valid, invalid or review with reasons in your language. By default the file is deleted when the analysis ends.
And for the record…
Create your account, copy the test key and validate your first document in five minutes.