PHP code example of prometee / vies-client

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

    

prometee / vies-client example snippets


$loader = etee\VIESClient\Soap\Client\DeferredViesSoapClient;
use Prometee\VIESClient\Soap\Client\ViesSoapClient;
use Prometee\VIESClient\Soap\Factory\ViesSoapClientFactory;
use Prometee\VIESClient\Helper\ViesHelper;

// Use the Deferred client to avoid getting error
// when the WSDL file is not accessible
$viesSoapClientFactory = ViesSoapClientFactory(ViesSoapClient::class);
$viesSoapClient = new DeferredViesSoapClient($viesSoapClientFactory);

$viesHelper = new ViesHelper($viesSoapClient);
$viesHelper->isValid('FR12345678987');

// Should print:
// 0: CHECK_STATUS_INVALID => Format is not valid and the webservice is not reachable)
// 1: CHECK_STATUS_INVALID_WEBSERVICE => Format is not valid according to the webservice
// 2: CHECK_STATUS_VALID_FORMAT => Format is valid but the webservice is not reachable
// 3: CHECK_STATUS_VALID_WEBSERVICE => Format is valid and the VAT number exists
print_r($viesHelper->isValid('FR12345678987'));