PHP code example of ecodenl / lvbag-php-wrapper

1. Go to this page and download the library: Download ecodenl/lvbag-php-wrapper 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/ */

    

ecodenl / lvbag-php-wrapper example snippets


use Ecodenl\LvbagPhpWrapper\Client;
use Ecodenl\LvbagPhpWrapper\Lvbag;
use Ecodenl\LvbagPhpWrapper\Resources\AdresUitgebreid;

$secret = 'asecretcodeyouneedtoobtain';
// crs is not static, you should change it accordingly to the desired call.
$acceptCRS = 'epsg:28992';

// Establish the connection
$client = Client::init($secret, $acceptCRS);

// Using the production environment endpoint
$shouldUseProductionEndpoint = true;
$client = Client::init($secret, $acceptCRS, $shouldUseProductionEndpoint);

// To get extensive logging from each request
// the client accepts any logger that follows the (PSR-3 standard)[https://github.com/php-fig/log]
// This example uses the logger from laravel, but feel free to pass any logger that implements the \Psr\Log\LoggerInterface
$logger = \Illuminate\Support\Facades\Log::getLogger();
$client = Client::init($secret, $acceptCRS, $shouldUseProductionEndpoint, $logger);

$lvbag = Lvbag::init($client);



// Get all available addresses from te given data
$addresses = $lvbag->adresUitgebreid()
  ->list([
    'postcode' => '3255MC',
    'huisnummer' => 13,
  ]);

// Only return the exact match 
$address = $lvbag->adresUitgebreid()
  ->list([
    'postcode' => '3255MC',
    'huisnummer' => 13,
    'exacteMatch' => true
  ]);
  
// Only return the exact match 
$address = $lvbag->adresUitgebreid()
  ->list([
    'postcode' => '3255MC',
    'huisnummer' => 13,
    'huisletter' => 'd',
    'exacteMatch' => true,
  ]);

$lvbag->adresUitgebreid()->show('1924200000030235');

// return page 2
$addresses = $lvbag->adresUitgebreid()
   ->page(2)
   ->list([
      'postcode' => '3255MC',
      'huisnummer' => 13,
   ]);
   
// Its also possible to change the amount per page.
$addresses = $lvbag->adresUitgebreid()
   ->pageSize(12)
   ->page(2)
   ->list([
      'postcode' => '3255MC',
      'huisnummer' => 13,
   ]);

$woonplaatsIdentification = '2134';
$woonplaats = $lvbag->woonplaats()->show($woonplaatsIdentification);

// Pass attributes as second parameter to retrieve more info
$woonplaats = $lvbag->woonplaats()->show($woonplaatsIdentification, [
    // Supports "bronhouders", "geometrie" or "true" (STRING!). "true" returns both.
    'expand' => 'bronhouders',  
]);

// This way one can retrieve the municipality of a city. 
$woonplaats['_embedded']['bronhouders']

$woonplaatsen = $lvbag->woonplaats()->list([
    'naam' => 'Oude-tonge',
    'expand' => 'bronhouders',  
]);

composer