Repository navigation
Including HeartBeat service checker
We love VIES service provided by the European Commission, but we also have to be realistic and acknowledge the service might not be accessible from time to time.
To help you verify if the service is up and running, I've added a HeartBeat functionality to the project that will just verify if the service is online before you start querying the service.
A typical example would be the following
<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
$vies = new \DragonBe\Vies\Vies();
if (false === $vies->getHeartBeat()->isAlive()) {
echo 'Service is not available at the moment, please try again later.' . PHP_EOL;
} else {
// Using my own VAT to verify, should be valid
$result = $vies->validateVat('BE', '0811231190');
echo ($result->isValid() ? 'VALID' : 'INVALID') . ' VAT number' . PHP_EOL;
// Using bogus VAT to verify, should be invalid
$result = $vies->validateVat('BE', '1234567890');
echo ($result->isValid() ? 'VALID' : 'INVALID') . ' VAT number' . PHP_EOL;
}I hope that this HeartBeat functionality will be a small, but valuable contribution to the project.