openfoodfacts / openfoodfacts-laravel
Open Food Facts API wrapper for Laravel
Fund package maintenance!
openfoodfacts
Installs: 19 476
Dependents: 0
Suggesters: 0
Security: 0
Stars: 151
Watchers: 14
Forks: 17
Open Issues: 2
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.4
- illuminate/support: ^9.0|^10.0|^11.0
- openfoodfacts/openfoodfacts-php: ^0.3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9.5
- larastan/larastan: ^2.9
- orchestra/testbench: ^7.0|^8.0|^9.0
- phpstan/phpstan: ^1.10
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^9.5.21|^10.5
README
Laravel Open Food Facts API
This package provides a convenient wrapper to the Open Food Facts API for Laravel applications.
Requirements
- PHP 8.1+
- Laravel 9.x, 10.x, 11.x
Installation
You can install the package via composer:
composer require openfoodfacts/openfoodfacts-laravel
Legacy support
- PHP 8.0 (Laravel <=9.x):
composer require "openfoodfacts/openfoodfacts-laravel:^0.3"
- PHP 7.2-7.4.x (Laravel 5.7-8.x):
composer require "openfoodfacts/openfoodfacts-laravel:^0.2"
Usage
Find product details by barcode
OpenFoodFacts::barcode('20203467');
it returns an array with product details:
Array
(
[product_name] => Cantuccini with hazelnuts
[image_url] => https://static.openfoodfacts.org/images/products/20203467/front_fr.4.400.jpg
...
)
Find products that match a search term:
$collection = OpenFoodFacts::find('Coca Cola Zero'); // returns a Illuminate\Support\Collection of arrays with details of each product found
Contributing
You're very welcome to contribute. We coordinate on the Open Food Facts slack, on the #PHP channel : https://slack.openfoodfacts.org Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
Third party applications
If you use this SDK, feel free to open a PR to add your application in this list.