Download the PHP package openfoodfacts/openfoodfacts-php without Composer

On this page you can find all versions of the php package openfoodfacts/openfoodfacts-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package openfoodfacts-php

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

Current features

Installation

With Composer:

Usage

This is the most basic way of creating the API:

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

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 you get an Object. This may also be an Object of Type ,, depending on which API you are creating. These objects inherit from the more generic

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

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

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


All versions of openfoodfacts-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
ext-curl Version *
ext-gd Version *
guzzlehttp/guzzle Version ^7.4
psr/log Version ^3.0
psr/simple-cache Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package openfoodfacts/openfoodfacts-php contains the following files

Loading the files please wait ....