All Projects โ†’ openfoodfacts โ†’ openfoodfacts-php

openfoodfacts / openfoodfacts-php

Licence: MIT license
PHP wrapper for Open Food Facts

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to openfoodfacts-php

Stayfit
๐Ÿ“ฑ ๐Ÿƒ ๐ŸŽ Fitness application thatโ€™s used to keep track of your physical fitness data, daily calorie count, invite friends to work out together and ultimately get healthy.
Stars: โœญ 90 (+83.67%)
Mutual labels:  food
Gourmet map
ๅพฎไฟกๅฐ็จ‹ๅบใ€Œ็พŽ้ฃŸๅœฐๅ›พใ€โ€”โ€”โ€œๅ‘็Žฐๆœ€ๅœฐ้“็š„็พŽ้ฃŸโ€
Stars: โœญ 129 (+163.27%)
Mutual labels:  food
Food2vec
๐Ÿ”
Stars: โœญ 199 (+306.12%)
Mutual labels:  food
Food 101 Mobile
Deep Learning Food Classifier for iOS using Keras and Tensorflow
Stars: โœญ 97 (+97.96%)
Mutual labels:  food
Fooddelivery
Design OO food delivery app with C# & Design Patterns
Stars: โœญ 126 (+157.14%)
Mutual labels:  food
Food Ordering System
Food or Item Order Management System
Stars: โœญ 161 (+228.57%)
Mutual labels:  food
Sustainable Green Plants
DIY high pressure aeroponics for the home
Stars: โœญ 84 (+71.43%)
Mutual labels:  food
Snap N Eat
Food detection and recommendation with deep learning
Stars: โœญ 229 (+367.35%)
Mutual labels:  food
Grocy Desktop
A (Windows) desktop application wrapper for https://github.com/grocy/grocy
Stars: โœญ 127 (+159.18%)
Mutual labels:  food
Food Ordering App
Stars: โœญ 198 (+304.08%)
Mutual labels:  food
Daily Dozen Ios
Keep track of the foods that Dr. Greger recommends in his NYT's best-selling book, How Not to Die with this iOS app
Stars: โœญ 109 (+122.45%)
Mutual labels:  food
Pwa Barcode Scanner
Information about food from the barcode, on your phone ๐Ÿ›’
Stars: โœญ 122 (+148.98%)
Mutual labels:  food
Swiggy Analytics
Analyse your swiggy orders ๐Ÿ”
Stars: โœญ 163 (+232.65%)
Mutual labels:  food
Addon Grocy
Grocy - Home Assistant Community Add-ons
Stars: โœญ 97 (+97.96%)
Mutual labels:  food
Openfoodfacts Ios
Native (Swift) version of Open Food Facts for iOS. Coders & Decoders welcome ๐Ÿคณ๐Ÿฅซ ๐Ÿ˜Š
Stars: โœญ 202 (+312.24%)
Mutual labels:  food
Taco Api
๐Ÿ‰ Brazilian Table of Food Composition (TACO) - JSON API
Stars: โœญ 87 (+77.55%)
Mutual labels:  food
Meanrecipe
Get a consensus recipe for your next meal. ๐Ÿช ๐Ÿฐ
Stars: โœญ 140 (+185.71%)
Mutual labels:  food
mealpy
Order your meals on MealPal automatically!
Stars: โœญ 28 (-42.86%)
Mutual labels:  food
Foodsoft
Web-based software to manage a non-profit food coop (product catalog, ordering, accounting, job scheduling).
Stars: โœญ 219 (+346.94%)
Mutual labels:  food
Grocy Docker
ERP beyond your fridge - now containerized - this is the docker repo of https://github.com/grocy/grocy
Stars: โœญ 164 (+234.69%)
Mutual labels:  food

openfoodfacts-php - Official PHP package for Open Food Facts

PHP API Wrapper for Open Food Facts, the open database about food.

Project Status Build Status Average time to resolve an issue Percentage of issues still open

Installation

With Composer:

composer require openfoodfacts/openfoodfacts-php

Usage

This is the most basic way of creating the API:

$api = new OpenFoodFacts\Api('food','fr');
$product = $api->getProduct('3057640385148');

In the example above you access the "food" database, limited to the French language/country scope. The first parameter is either

  • "food"
  • "beauty" or
  • "pet"

to decide which product database you want to use.

The second parameter decides the language/country scope of the chosen database: f.e. "world" or "de" or "fr".

For more details on this topic: see the API Documentation

These are all the parameters you really need for basic usage.

As return types for $api->getProduct you get an Document::class Object. This may also be an Object of Type FoodProduct::class,PetProduct::class, BeautyProduct::class depending on which API you are creating. These objects inherit from the more generic Document::class

In the example above, we use the 'food' API and there will get a FoodProduct::class

For getting a first overview the Document::class has a function to return an array representation(sorted) for a first start.

$product = $api->getProduct('3057640385148');
$productDataAsArray = $product->getData();

Optional Parameters

The other parameters are optional and for a more sophisticated use of the api (from a software development point of view):

An example in code is found here: cached_example.php

LoggerInterface: A logger which decieds where to log errors to (file, console , etc)

see: PSR-3 Loggerinterface

ClientInterface: The HTTP Client - to adjust the connection configs to your needs and more

see: Guzzle HTTP Client

CacheInterface: To temporarily save the results of API request to improve the performance and to reduce the load on the API- Server

see: PSR-16 Simple Cache

Development

Contributing

  1. Fork it ( https://github.com/openfoodfacts/openfoodfacts-php/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Launch test vendor/bin/phpunit && cs-fixer vendor/bin/php-cs-fixer fix
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

Third party applications

If you use this SDK, feel free to open a PR to add your application in this list.

Authors

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].