PHP code example of lufiipe / insee-sierene

1. Go to this page and download the library: Download lufiipe/insee-sierene 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/ */

    

lufiipe / insee-sierene example snippets



use LuFiipe\InseeSierene\Exception\SireneException;
use LuFiipe\InseeSierene\Parameters\SearchParameters;
use LuFiipe\InseeSierene\Sirene;

$sirene = new Sirene('YOUR-API-KEY');

// Get legal entity details by SIREN number
$sirene->siren('120027016')->getBody();

// Get establishment details by SIRET Number
$sirene->siret('12002701600563')->getBody();

// Searches for legal entities whose name currently contains or previously contained the term "INSEE"
$parameters = (new SearchParameters)
    ->setQuery('periode(denominationUniteLegale:INSEE)');
$collection = $sirene->searchLegalUnits($parameters);
$collection->each(function (array $legalUnit) {
    var_dump($legalUnit);
});

// Retrieves establishments containing the name "WWF"
$parameters = (new SearchParameters)
    ->setQuery('denominationUniteLegale:"WWF"');
$collection = $sirene->searchEstablishments($parameters);
$collection->each(function (array $establishment) {
    var_dump($establishment);
});

// INSEE Sirene Service Status
try {
    $res = $sirene->informations();
} catch (SireneException $e) {
    // ../..
}