PHPackages                             ph-7/eu-vat-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. ph-7/eu-vat-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

ph-7/eu-vat-validator
=====================

A simple and clean PHP class that validates EU VAT numbers against the central ec.europa.eu database (using the official europa API).

3.1(3y ago)95464.2k—8.8%19[2 issues](https://github.com/pH-7/eu-vat-validator/issues)[1 PRs](https://github.com/pH-7/eu-vat-validator/pulls)1GPL-3.0-or-laterPHPPHP &gt;=7.1.0

Since Jan 22Pushed 1y ago7 watchersCompare

[ Source](https://github.com/pH-7/eu-vat-validator)[ Packagist](https://packagist.org/packages/ph-7/eu-vat-validator)[ Docs](https://pierrehenry.be)[ GitHub Sponsors](https://github.com/pH-7)[ Fund](https://ko-fi.com/phenry)[ RSS](/packages/ph-7-eu-vat-validator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (1)

EU VAT Number Validator
=======================

[](#eu-vat-number-validator)

A simple and clean PHP class that validates EU VAT numbers against the central ec.europa.eu database (using the official europa API).

[![EU VATIN validator; EU Flag](eu-flag.svg)](eu-flag.svg)

The Problem
-----------

[](#the-problem)

Validate VAT numbers might be difficult and if you use a validation pattern to check if the format is valid, you are never sure if the VAT registration number is still valid.

The Solution
------------

[](#the-solution)

This [PHP VAT validator library](https://github.com/pH-7/eu-vat-validator) uses real-time data feeds from individual EU member states' VAT systems so you are sure of the validity of the number and avoid fraud with expired or wrong VAT numbers.

For example, this kind of validation can be very useful on online payment forms.

Composer Installation
---------------------

[](#composer-installation)

- Be sure PHP **[v7.1](https://www.php.net/releases/7_1_0.php) or higher** is installed.
- Install Composer ().
- Then, include it in your project like belowe,

```
composer require ph-7/eu-vat-validator
```

- Then, include Composer's autoload (if not already done in your project)

```
require_once 'vendor/autoload.php';
```

Manual Installation (*the old-fashioned way*)
---------------------------------------------

[](#manual-installation-the-old-fashioned-way)

If you don't use Composer, you can install it without Composer by including the following

```
require 'src/autoloader.php';
```

How to Use
----------

[](#how-to-use)

### Example

[](#example)

```
use PH7\Eu\Vat\Validator;
use PH7\Eu\Vat\Provider\Europa;

$oVatValidator = new Validator(new Europa, '0472429986', 'BE');

if ($oVatValidator->check()) {
    $sRequestDate = $oVatValidator->getRequestDate();
    // Optional, format the date
    $sFormattedRequestDate = (new DateTime)->format('d-m-Y');

    echo 'Business Name: ' . $oVatValidator->getName() . '';
    echo 'Address: ' . $oVatValidator->getAddress() . '';
    echo 'Request Date: ' . $sFormattedRequestDate . '';
    echo 'Member State: ' . $oVatValidator->getCountryCode() . '';
    echo 'VAT Number: ' . $oVatValidator->getVatNumber() . '';
} else {
    echo 'Invalid VAT number';
}
```

Optimization (Suggestion)
-------------------------

[](#optimization-suggestion)

Depending of the use of this library, it could be handy to cache the result specifically for each specified VAT number.

Requirements
------------

[](#requirements)

- PHP 7.1 or higher
- [Composer](https://getcomposer.org)
- [SOAPClient](http://php.net/manual/en/class.soapclient.php) PHP Extension enabled

About Me
--------

[](#about-me)

I'm **[Pierre-Henry Soria](https://pierrehenry.be)**, a passionate Software Engineer and the creator of [pH7CMS](https://github.com/pH7Software/pH7-Social-Dating-CMS).

Where to Contact Me?
--------------------

[](#where-to-contact-me)

You can by email at **pierrehenrysoria+github \[\[AT\]\] gmail \[\[D0T\]\] com**

Wordpress Plugin
----------------

[](#wordpress-plugin)

[VIES Validator WP plugin](https://wordpress.org/plugins/vies-validator/) uses also this [EU VAT Validation library](https://github.com/pH-7/eu-vat-validator/) for WooCommerce checkout, when you need to make sure that the VAT number is valid (that plugin was deleloped by [WpZen](https://wpzen.it), not me 😃).

References
----------

[](#references)

[VAT Information Exchange System (VIES)](http://ec.europa.eu/taxation_customs/vies/)

License
-------

[](#license)

Under [General Public License 3](http://www.gnu.org/licenses/gpl.html) or later.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~181 days

Recently: every ~341 days

Total

13

Last Release

1231d ago

Major Versions

1.0 → 2.02017-01-22

2.9 → 3.02022-05-10

PHP version history (2 changes)1.0PHP &gt;=7.0.0

2.9PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b6d95da236687f1dca4f7d70d60037c70ef217120ea195df23a39a412ba594e0?d=identicon)[ph-7](/maintainers/ph-7)

---

Top Contributors

[![pH-7](https://avatars.githubusercontent.com/u/1325411?v=4)](https://github.com/pH-7 "pH-7 (71 commits)")

---

Tags

businessbusinessescompaniescompanyeueu-apieu-vateu-vat-validatoreuropaeuropa-apiphp-7php7taxvalidationvat-numbervat-validationvat-validatorvat-valirationvatinviesvalidatorvalidationvatviesvat-validatorvat numberTVAeu vatvalidate eu vatvalidate vat numbervat number validatortva number

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ph-7-eu-vat-validator/health.svg)

```
[![Health](https://phpackages.com/badges/ph-7-eu-vat-validator/health.svg)](https://phpackages.com/packages/ph-7-eu-vat-validator)
```

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[opis/json-schema

Json Schema Validator for PHP

64736.9M186](/packages/opis-json-schema)[vlucas/valitron

Simple, elegant, stand-alone validation library with NO dependencies

1.6k4.4M128](/packages/vlucas-valitron)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[ronanguilloux/isocodes

PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Book and Music Industries, Phone numbers &amp; Zipcodes for many countries

8013.3M23](/packages/ronanguilloux-isocodes)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
