1. Go to this page and download the library: Download metapixel/postcodeapi 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/ */
metapixel / postcodeapi example snippets
class PostcodeAPISubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
PreSearchRequestEvent::NAME => 'onPreSearchRequestEvent',
];
}
public function onPreSearchRequestEvent(PreSearchRequestEvent $event): void
{
$cachedAddress = new Address();
$cachedAddress->setCountry('Nederland');
$cachedAddress->setCountryCode('nl');
$cachedAddress->setCity('Amsterdam');
$event->setAddress($cachedAddress);
}
}
use Metapixel\PostcodeAPI\Provider\nl_NL\Pro6PP;
/** @var Pro6PP $provider */
$provider = ProviderFactory::create('nl_NL.Pro6PP');
$provider->setApiKey('YOUR_API_KEY');
// Optionally add an event subscriber or event listener.
$subscriber = new PostcodeAPISubscriber();
$provider->dispatcher->addSubscriber($subscriber);
$address = $provider->findByZipcodeAndHouseNumber('1068NM', '461');
$provider = ProviderFactory::create('nl_NL.Pro6PP');
$provider->setApiKey('YOUR_API_KEY');
$provider->find('1068NM');
$provider->findByZipcode('1068NM');
$provider->findByZipcodeAndHousenumber('1068NM', '461');
// Using the more dynamic SearchRequest entity
$searchRequest = (new SearchRequest())
->setZipcode($zipcode)
->setHouseNumber($houseNumber);
$provider->findBySearchRequest($searchRequest);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.