Skip to content
Constaia

Symfony

Validate documents with AI in Symfony

Register the Constaia client as a service and use it in your controllers.

Installation

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 result. If you do not have a server, use the widget with a publishable key.

Full guide
src/Controller/VerifyController.php
<?php

namespace App\Controller;

use Constaia\Client;
use Symfony\Component\HttpFoundation\{JsonResponse, Request};
use Symfony\Component\Routing\Attribute\Route;

final class VerifyController
{
    public function __construct(private readonly Client $constaia) {}

    #[Route('/api/verify', methods: ['POST'])]
    public function __invoke(Request $request): JsonResponse
    {
        $file = $request->files->get('file');
        $analysis = $this->constaia->analyze($file, [
            'expect' => 'es_dni',
            'checks' => ['not_expired' => true],
        ]);

        return new JsonResponse(['status' => $analysis->verdictStatus()]);
    }
}

One call. An answer you can act on.

  1. 01

    Send the document and what you expect

    A photo, screenshot or PDF. Say which document you expect and the rules: in date, less than 6 months old, in this person's name.

  2. 02

    We read, classify and check

    Text reading, AI classification and fixed checks: Spanish ID number check letter, machine readable zone, IBAN, dates and totals.

  3. 03

    Get the verdict and the file is deleted

    Valid, invalid or review, with the reasons in your language. By default, the file is deleted at the end unless it needs review.

And for the record…

Create your free account and validate your first document in five minutes. No card required.