PHP code example of weareantenna / vat

1. Go to this page and download the library: Download weareantenna/vat 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/ */

    

weareantenna / vat example snippets




use Antenna\Vat\VatNumber;
use Antenna\Vat\ViesValidator\SoapViesValidator;

$vatNumber = new VatNumber('BE0123 456 749');
$validator = new SoapViesValidator();

echo $vatNumber->toString(); // BE0123 456 749
echo $vatNumber->toNormalizedString(); // BE0123456749

if ($vatNumber->isFormatValid()) {
    try {
        $isRegistered = $validator->isValid($vatNumber); 
    } catch (RuntimeException $e) {
        // something went wrong when trying to validate against VIES
    }
}



use Antenna\Vat\VatNumber;
use Antenna\Vat\Formatter\TeamleaderFormatter;

$formatter = new TeamleaderFormatter();

echo $formatter->format(new VatNumber('BE0123456749')); // BE 0123.456.749
echo $formatter->format(new VatNumber('NL001632553B28')); // NL 0016.32.553.B28