cvilleger / geo-gouv
Simple Geo Gouv Library. Query geographic reference data.
0.3.0
2026-01-27 16:25 UTC
Requires
- php: ^8.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.93
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.5
- rector/rector: ^2.3
- vimeo/psalm: ^6.14
README
cvilleger/geo-gouv
About
Query geographic reference data using offline data from 🇫🇷 Gouv administrative division API.
Features
- Query all departments data
- Query all municipalities by department code
Requirements
- PHP 8.5 or above
Installation
Install this package as a dependency using Composer.
composer require cvilleger/geo-gouv
Note that this package has zero composer dependencies.
Usage
Retrieve departments
use Cvilleger\GeoGouv\Client; print_r(new Client()->getDepartements()[0]); /* Cvilleger\GeoGouv\Model\Departement Object ( [nom] => Ain [code] => 01 [codeRegion] => 84 [coordinates] => 46.06551335, 5.28478031423462 [region] => Cvilleger\GeoGouv\Model\Region Object ( [nom] => Auvergne-Rhône-Alpes [code] => 84 ) ) */
Retrieve municipalities by department code
use Cvilleger\GeoGouv\Client; print_r(new Client()->getCommunesByDepartementCode('01')[0]); /* ( [nom] => L'Abergement-Clémenciat [code] => 01001 [codesPostaux] => Array ( [0] => 01400 ) [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 ) ) */