PHP code example of kefivitch / tunisian-municipality-api

1. Go to this page and download the library: Download kefivitch/tunisian-municipality-api 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/ */

    

kefivitch / tunisian-municipality-api example snippets


// config/app.php
'providers' => [
    TunisianMunicipality\\TunisianMunicipalityServiceProvider::class,
],

'aliases' => [
    'TunisianMunicipality' => TunisianMunicipality\\Facades\\TunisianMunicipality::class,
],

use TunisianMunicipality\\Facades\\TunisianMunicipality;

$municipalities = TunisianMunicipality::getMunicipalities();
// $municipalities is an Illuminate\\Support\\Collection instance

// Retrieve municipalities that match the provided filters
$filtered = TunisianMunicipality::getMunicipalities([
    'name' => 'Tunis',    // filter by municipality name
    // other supported filters can be passed here
]);

use GuzzleHttp\\Client;
use TunisianMunicipality\\TunisianMunicipality as MunicipalityClient;

$client = new MunicipalityClient(new Client(), 'https://tn-municipality-api.vercel.app/api');
$all = $client->getMunicipalities();