bernskiold / laravel-euromonitor
A package for Laravel to interact with the Euromonitor API.
Requires
- php: ^8.2|^8.3|^8.4
- illuminate/contracts: ^11.0|^12.0|^13.0
- laravel/prompts: ^0.1.18|^0.2.0|^0.3.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0|^9.0
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^2.0|^3.0|^4.0
- pestphp/pest-plugin-laravel: ^2.0|^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Installation & Usage
You can install the package via composer:
composer require bernskiold/laravel-euromonitor
After installing the package, you may publish the configuration file:
php artisan vendor:publish --provider="Bernskiold\LaravelEuromonitor\LaravelEuromonitorServiceProvider" --tag="config"
This will publish a euromonitor.php file in your config directory.
The core configuration parameters for connecting to the Euromonitor API are provided
as environment variables in your .env file. These are:
EUROMONITOR_USERNAME= EUROMONITOR_PASSWORD= EUROMONITOR_API_KEY=
Company and brand identifiers
Euromonitor's catalog exposes stable identifiers for companies and brands. Use them to look entities up once and then filter the share services by ID, rather than matching on names.
use Bernskiold\LaravelEuromonitor\Facades\Euromonitor; // Every brand your subscription can see, with its owning company. $brands = Euromonitor::brands() ->geographies([21]) // Belgium ->categories([11069]) // Toilet Paper ->page(1) ->perPage(1000) ->all() ->get(); $brands->first()->brandId; // 903112 $brands->first()->brandName; // "Lotus" $brands->first()->companyId; // 674613 // Companies only. $companies = Euromonitor::companies()->all()->get();
Both endpoints are paginated with page() and perPage() (maximum 10,000 records
per page) and return one record per geography and category combination, so the same
brandId appears more than once across a full listing.
Filtering share data by identifier
brandShares() accepts both brands() and companies(); companyShares() accepts
companies(). This works for live queries and for mass extraction jobs.
$shares = Euromonitor::brandShares() ->percentages() ->shareType(0) ->geographies([21]) ->categories([11069]) ->brands([903112, 903118]) ->all() ->get(); $shares->first()->brandId; // 903112 $shares->first()->companyId; // 674613 $shares->first()->entityId(); // 903112 - the brand on a brand share $shares->first()->entityName(); // "Lotus"
Share records expose brandId and companyId alongside the names. Both are
nullable, since extract files produced before the identifiers were introduced do
not carry them - use hasEntityId() when you need to branch on that.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.