belghiti/laravel-rest-vies

Laravel 12 integration for belghiti/vies-client (Belghiti\Vies).

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/belghiti/laravel-rest-vies

v0.1.2 2026-02-23 15:37 UTC

This package is auto-updated.

Last update: 2026-02-24 14:28:07 UTC


README

CI Packagist Downloads

Laravel 12 integration for VIES: Service Provider + Facade + Validation Rule + Cache decorator. It wires the core belghiti/vies-client with retry and Laravel Cache.

Requirements

  • Laravel 12.x
  • PHP 8.2 – 8.5

Installation

composer require belghiti/laravel-rest-vies
php artisan vendor:publish --tag=vies-config

config/vies.php

return [
    'base_uri'  => env('VIES_BASE_URI', 'https://ec.europa.eu/taxation_customs/vies/rest-api'),
    'cache_ttl' => (int) env('VIES_CACHE_TTL', 3600),
];

.env

VIES_BASE_URI=https://ec.europa.eu/taxation_customs/vies/rest-api
VIES_CACHE_TTL=3600

Usage

Facade

use Vies; // Belghiti\Vies\Laravel\ViesFacade alias
use Belghiti\Vies\Dto\CheckVatRequest;

$res = Vies::checkVatNumber(new CheckVatRequest('FR', '40303265045'));
if ($res->valid) {
    // ...
}

Dependency Injection

use Belghiti\Vies\Client\ViesClientInterface;
use Belghiti\Vies\Dto\CheckVatRequest;

public function __construct(private ViesClientInterface $vies) {}

public function __invoke()
{
    $status = $vies->checkStatus();
    // ...
}

Validation Rule

use Belghiti\Vies\Laravel\Rules\ValidVatInVies;
use Illuminate\Support\Facades\Validator;

$validator = Validator::make(
  ['vat' => '40303265045'],
  ['vat' => [new ValidVatInVies(app(\Belghiti\Vies\Client\ViesClientInterface::class), 'FR')]]
);

Notes

  • CheckVatRequest covers the contract fields (countryCode, vatNumber, optional trader info)
  • The package caches checkVatNumber() responses using your configured Laravel Cache store (TTL from config)

Quality

composer lint   # PSR-12
composer stan   # PHPStan level max
vendor/bin/pest -d

License

MIT