kfoobar/laravel-euro-vat

A Laravel package for Euro VAT validation

Maintainers

Package info

github.com/KFoobar/laravel-eu-vat

Homepage

Issues

pkg:composer/kfoobar/laravel-euro-vat

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

v1.0.1 2026-04-01 21:51 UTC

This package is auto-updated.

Last update: 2026-04-01 21:52:27 UTC


README

A Laravel package for validating EU VAT numbers, including local format validation and online validation against the EU VIES API.

Installation

Install the package via Composer:

composer require kfoobar/laravel-euro-vat

Publish the configuration file:

php artisan vendor:publish --provider="KFoobar\EuroVAT\EuroVATServiceProvider"

Configuration

The configuration file config/euro-vat.php allows you to set:

  • urls.number: Endpoint used when validating a VAT number online.
  • urls.status: Endpoint used for the VIES status check.
  • ttl.number: Cache lifetime in minutes for VAT validation results.
  • ttl.status: Cache lifetime in minutes for VIES status results.

Usage

The main service exposes:

  • validate(string $number, ?string $country = null): ?string
  • validateOffline(string $number, ?string $country = null): ?string
  • validateOnline(string $number, string $country): ?string
  • status(?string $country = null): bool

Using the Facade

Validate a VAT number:

use KFoobar\EuroVAT\Facades\EuroVAT;

EuroVAT::validate('SE123456789012');
EuroVAT::validateOffline('SE123456789012');
EuroVAT::validateOnline('123456789012', 'SE');
EuroVAT::validate('123456789012', 'SE');
EuroVAT::status('SE');

validate() is the default entrypoint and performs online validation.

validateOffline() only performs the local VAT format check. No external HTTP request is made.

validateOnline() sends the provided VAT number and country code directly to the EU VIES API and caches the response. It does not normalize or pre-validate the VAT number locally.

Using the Validation Rule

use KFoobar\EuroVAT\Rules\VatId;

$request->validate([
    'vat_number' => ['required', new VatId('SE')],
]);

Using the vat_id Validator Extension

$request->validate([
    'vat_number' => 'required|vat_id:SE',
]);

Contributing

Contributions are welcome!

License

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