aichadigital/lararoi

Agnostic package for intra-community NIF-VAT/VAT verification. Designed primarily for use with Larabill.

Maintainers

Package info

github.com/AichaDigital/lararoi

Homepage

pkg:composer/aichadigital/lararoi

Transparency log

Fund package maintenance!

:vendor_name

Statistics

Installs: 1 987

Dependents: 1

Suggesters: 0

Stars: 0

v1.1.0 2026-07-11 17:48 UTC

README

Latest Version Total Downloads Pipeline Coverage PHPStan level 5 PHP Version Laravel Version License

Development happens on gitlab.castris.com. The GitHub repository is a read-only distribution mirror: issues and pull requests opened there are not seen.

Latest Version on Packagist GitHub Tests Action Status PHPStan Code Style Total Downloads

Lararoi is the Laravel package that owns the intra-community VAT/NIF verification domain: the verification itself, its cache, and a multi-consumer tracking/audit log — served to consuming apps through explicit, stable contracts and agnostic configuration. Consumers (billing, accounting, …) consume it; they never reimplement the domain.

The verification model is provider-agnostic (VIES SOAP/REST, isvat, viesapi, vatlayer) with automatic fallback and per-country syntax validation. See the architecture decisions (ADR-001, ADR-002) for the domain-ownership rationale.

Features

  • ✅ VAT/NIF verification via VIES (European Commission) + multiple free/paid providers, with automatic fallback
  • ✅ Per-country syntax validation (short-circuits obviously invalid numbers without hitting a provider)
  • ✅ TTL cache (memory + database), one current row per NIF, enforced by a UNIQUE key
  • Multi-consumer tracking / audit log — append-only, consumer-attributed, inert by default
  • Per-consumer retention (declared in config, UTC) with a prune command
  • Per-consumer output mapping — adapt the canonical result to your own shape without forking code
  • Formal, documented contract set — swap the model, the tracking model, or the mapper via config/contracts
  • ✅ Robust, typed error handling; development commands for testing against real APIs

Requirements

  • PHP 8.3+
  • Laravel 12+

Installation

composer require aichadigital/lararoi

The database schema is package-managed — just run migrations, no stub to publish:

php artisan migrate

This creates the cache table roi_vat_verifications and the tracking table roi_verification_queries. Optionally publish the config to tune providers, cache, tracking and retention:

php artisan vendor:publish --tag="lararoi-config"

Basic Usage

use Aichadigital\Lararoi\Contracts\VatVerificationServiceInterface;

$result = app(VatVerificationServiceInterface::class)
    ->verifyVatNumber('B12345678', 'ES');

if ($result['is_valid']) {
    echo "Valid VAT: {$result['company_name']}";
}

Tracking is off by default. A consumer that wants an audit trail enables lararoi.tracking.enabled, registers itself in the lararoi.consumers allow-list (with a retention policy), and passes a VerificationContext — see the Integration Guide.

Documentation

Testing & Quality

  • Pest PHP test suite, PHPStan level 5, Laravel Pint, GitHub Actions CI.
composer test        # run the suite
composer quality     # pint + phpstan + tests

License

The MIT License (MIT). Please see License File for more information.

Credits