mmockelyn/laravel-insee

Lookup SIREN and SIRET numbers from Laravel

dev-master 2021-01-17 00:00 UTC

This package is not auto-updated.

Last update: 2024-04-23 09:53:43 UTC


README

This package is a Laravel wrapper allowing you to lookup SIREN and SIRET numbers of French businesses and nonprofit associations, attributed by Insee (Institut national de la statistique et des études économiques).

Laravel Insee uses the Sirene V3 API.

Installation

You can install this package via Composer:

composer require nspehler/laravel-insee

If you are using Laravel 5.5 or later, the service provider and facade will be discovered automatically.

On earlier versions, you need to do that manually. You must install the service provider:

// config/app.php
'providers' => [
    ...
    NSpehler\LaravelInsee\InseeServiceProvider::class,
];

And register an alias for the Insee facade:

// config/app.php
'aliases' => [
    ...
    'Insee' => NSpehler\LaravelInsee\Facades\Insee::class,
];

Configuration

To get started, sign up on https://api.insee.fr and create a new application. From the "Production Keys" tab, you'll be able to generate your Consumer Key and Consumer Secret.

Make sure to subscribe your new app to the Sirene V3 API to grant it access.

Then, you can add your production keys as environment variables in your .env file:

INSEE_CONSUMER_KEY=
INSEE_CONSUMER_SECRET=

Optionally, you can edit the name of these variables by publishing the configuration file:

php artisan vendor:publish --provider="NSpehler\LaravelInsee\InseeServiceProvider" --tag="config"

Usage

Use the Insee facade to lookup a SIREN or SIRET number:

Insee::siren('840 745 111');
Insee::siret('840 745 111 00012');

Credits

Testing

68747470733a2f2f6465762e6c732e6167656e63792f696d672f42726f77736572537461636b2d4c6f676f2e737667

This project uses BrowserStack for cross browser testing. We're grateful for their contribution to the open source community.

License

The MIT License (MIT). Please see License File for more information.