cvilleger/geo-gouv

Simple Geo Gouv Library. Query geographic reference data.

Maintainers

Package info

github.com/cvilleger/geo-gouv

pkg:composer/cvilleger/geo-gouv

Statistics

Installs: 3 414

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.3.0 2026-01-27 16:25 UTC

This package is auto-updated.

Last update: 2026-03-01 00:49:50 UTC


README

GitHub Actions Workflow Status Packagist Version Packagist Downloads GitHub License

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
        )
)
*/