openfoodfacts/openfoodfacts-laravel

Open Food Facts API wrapper for Laravel

v0.3.0 2022-02-08 12:08 UTC

README

68747470733a2f2f7374617469632e6f70656e666f6f6466616374732e6f72672f696d616765732f6c6f676f732f6f66662d6c6f676f2d686f72697a6f6e74616c2d6c696768742e737667

Laravel Open Food Facts API

Latest Version on Packagist Code Coverage Quality Score

This package provides a convenient wrapper to the Open Food Facts API for Laravel applications.

Requirements

  • PHP 8.0+
  • Laravel 9.x

Legacy support (PHP 7.2+ and Laravel 5.7-8.x) at v0.2.x.

Installation

You can install the package via composer:

composer require openfoodfacts/openfoodfacts-laravel

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.

Authors