Skip to content

Including HeartBeat service checker

Choose a tag to compare

@DragonBe DragonBe released this 30 Jan 07:49
· 353 commits to master since this release

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.