PHP code example of api-check / php-laravel-client

1. Go to this page and download the library: Download api-check/php-laravel-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/ */

    

api-check / php-laravel-client example snippets



$address = ApiCheck::api()->lookup('nl', 'postalcode' => '2513AA', 'number' => 1]);

// Do something with the result:
print("🥳 Yay! We have a result: \n $address->street $address->number \n $address->postalcode $address->city \n {$address->Country->name}");

$results = ApiCheck::api()->search('be', 'city', ['name' => 'Namur']);

use ApiCheck\Api\ApiClient;
use ApiCheck\Api\Exceptions\NotFoundException;
use ApiCheck\Api\Exceptions\ValidationException;
use ApiCheck\Api\Exceptions\UnsupportedCountryException;

try {
    $address = $apicheckClient->lookup('nl', ['postalcode' => '2513AA', 'number' => 1]);
} catch (NotFoundException $e) {
    // No results have been found using the supplied data
} catch (ValidationException $e) {
    // One of the submitted fields is not valid or set
} catch (UnsupportedCountryException $e) {
    // The given country-code is not supported
}
bash
$ composer