Download the PHP package mlocati/vat-lib without Composer

On this page you can find all versions of the php package mlocati/vat-lib. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package vat-lib

Tests

A PHP library to validate and normalize and VAT numbers

This project provides a library that checks and normalizes VAT numbers (including querying the VIES VoW (VAT Information Exchange System - Vies-on-the-web service for European countries).

Requirements

VATLib has these requirements:

Installation

Manual installation

Download the latest version, unzip it and add these lines in our PHP files:

Installation with Composer

Simply run:

or add these lines to your composer.json file:

Checking and normalizing VAT numbers

You can use the VATLib\Checker class to validate and normalize VAT numbers.

You can obtain an instance of it simply with:

You can then use its check method. This method accepts one to two arguments: the first argument is the VAT number to be checked, the second argument (optional) is the ISO 3166 alpha-2 code of the Country associated to that VAT number.

Some examples (that lead to the same valid result):

Verifying the validity

$checkResult provides the isSyntaxValid() method, which returns:

When the VAT number is syntactically valid, the library also queries the VIES service for EU countries.

You can check the VIES response with some code like this:

$checkResult provides a quick way to check both isSyntaxValid() and the VIES result: you can use its isValid() method, which returns:

Retrieving the formatted VAT number

To obtain the normalized VAT number, you can use the getShortVatNumber() or the getLongVatNumber() methods of $checkResult:

Getting VAT number info

You can obtain some details about a VAT number:

The code above would print:

Checking for errors

Unexpected problems may occur when checking VAT numbers (for example, because the VIES service is temporarily not available).

You can check if any errors occurred using the hasExceptions method of $checkResult:

Detecting the possible countries given a VAT number

If you have a generic VAT number and you would like to know the possible countries where it may be defined, you can use the getApplicableFormats() method of the VATLib\Checker class:

The code above would print:

Checking the status of the VIES service

Manually querying VIES

You can also query VIES directly:

The code above may output:

Customizing the HTTP adapter for VIES

By default, VATLib automatically detects the available adapter, but of course you can specify your own.

For example, if you are using Guzzle and you need to configure a proxy, you can write something like this:

The same can be done using the cURL PHP extension:

The same can be done using the http stream wrapper:

Supported countries

The library supports these countries:


All versions of vat-lib with dependencies

PHP Build Version
Package Version
Requires php Version ^5.5 || ^7 || ^8
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mlocati/vat-lib contains the following files

Loading the files please wait ....