1. Go to this page and download the library: Download jairforo/php-vat-checker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jairforo / php-vat-checker example snippets
use JairForo\VATChecker\Exceptions\VATCheckerException;
use JairForo\VATChecker\VATChecker;
try {
/** @var bool $isValid */
$isValid = (new VATChecker())->isValid($countryCode, $vatNumber);
} catch (VATCheckerException $exception) {
// Something went wrong during the request.
}
use JairForo\VATChecker\Exceptions\InvalidVATException;
use JairForo\VATChecker\Exceptions\VATCheckerException;
use JairForo\VATChecker\Objects\VATResponse;
use JairForo\VATChecker\VATChecker;
try {
/** @var VATResponse $vatResponse */
$vatResponse = (new VATChecker())->check($countryCode, $vatNumber);
print_r($vatResponse);
} catch (VATCheckerException $exception) {
if ($exception instanceof InvalidVATException) {
// The VAT information was invalid.
return;
}
// Something else went wrong during the request.
}