1. Go to this page and download the library: Download lodge/postcode-lookup 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/ */
// First of all you need to instantiate the class
// And assuming that you have google-api-key';
$postcode = new Lodge\Postcode\Postcode($googleApiKey);
$results = $postcode->lookup('SW3 4SZ');
print_r($results);
// Outputs
array(
'postcode' => 'SW34SZ',
'street_number' => '',
'street' => '',
'sublocality' => '',
'town' => 'London',
'county' => 'Greater London',
'country' => 'United Kingdom',
'latitude' => 51.489117499999999,
'longitude' => -0.1579016
)