PHP code example of api-postcode / api-postcode-laravel

1. Go to this page and download the library: Download api-postcode/api-postcode-laravel 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-postcode / api-postcode-laravel example snippets

 php
ApiPostcode\ApiPostcodeServiceProvider::class,
 php
'aliases' => [
    //...
    'Postcode' => ApiPostcode\Facade\Postcode::class,
];

php artisan vendor:publish --provider="ApiPostcode\ApiPostcodeServiceProvider"
 php
$address = app('api.postcode')->fetchAddress('1012JS', 1);
	
$address->getStreet();      // Dam
$address->getCity();        // Amsterdam
$address->getHouseNumber(); // 1
$address->getZipCode();     // 1012JS
$address->getLongitude();   // 4.4584
$address->getLatitude();    // 52.2296
 php
$address = Postcode::fetchAddress('1012JS', '1')
 php
$router->get('postcode/{zipCode}/{number}', function ($zipCode, $number) {
    return Postcode::fetchAddress($zipCode, $number);
});