cvilleger / geo-gouv
Simple Geo Gouv Library. Query geographic reference data more easily.
0.1.2
2024-10-09 10:12 UTC
Requires
- php: ^8.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^11.4
README
cvilleger/geo-gouv
About
Query geographic reference data more easily using offline data from Gouv administrative division API.
Features
- Query all departments data
- Query all municipalities by department code
Requirements
cvilleger/geo-gouv
requires at least PHP 8.2
Installation
Install this package as a dependency using Composer.
composer require cvilleger/geo-gouv
Usage
Retrieve all departments
use Cvilleger\GeoGouv\Client; $client = new Client(); $departements = $client->getDepartements(); print_r($departements[0]); /* Cvilleger\GeoGouv\Model\Departement Object ( [nom] => Ain [code] => 01 [codeRegion] => 84 [region] => Cvilleger\GeoGouv\Model\Region Object ( [nom] => Auvergne-Rhône-Alpes [code] => 84 ) ) */
Retrieve all municipalities by department code
use Cvilleger\GeoGouv\Client; $client = new Client(); $communes = $client->getCommunesByDepartementCode('01'); print_r($communes[0]); /* ( [nom] => L'Abergement-Clémenciat [code] => 01001 [codesPostaux] => Array ( [0] => 01400 ) [centre] => Cvilleger\GeoGouv\Model\Centre Object ( [type] => Point [coordinates] => Array ( [0] => 4.9306 [1] => 46.1517 ) ) [surface] => 1564.5 [population] => 832 [departement] => Cvilleger\GeoGouv\Model\CommuneDepartement Object ( [nom] => Ain [code] => 01 ) [region] => Cvilleger\GeoGouv\Model\CommuneRegion Object ( [nom] => Auvergne-Rhône-Alpes [code] => 84 ) ) */