Skip to content

Commit

Permalink
Merge pull request #13 from Dwarfex/cache-DI
Browse files Browse the repository at this point in the history
Cache & HTTP Client DI
  • Loading branch information
rampmaster authored Oct 4, 2019
2 parents deeef6c + 3b00f46 commit d5fc3b1
Show file tree
Hide file tree
Showing 11 changed files with 467 additions and 118 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
PHP API Wrapper for [Open Food Facts](https://openfoodfacts.org/), the open database about food.

[![Project Status](http://opensource.box.com/badges/active.svg)](http://opensource.box.com/badges)
[![Build Status](https://travis-ci.org/openfoodfacts/openfoodfacts-php.svg?branch=master)](https://travis-ci.org/openfoodfacts/openfoodfacts-php) [![Stories in Ready](https://badge.waffle.io/openfoodfacts/openfoodfacts-php.svg?label=ready&title=Ready)](https://waffle.io/openfoodfacts/openfoodfacts-php)
[![Build Status](https://travis-ci.org/openfoodfacts/openfoodfacts-php.svg?branch=master)](https://travis-ci.org/openfoodfacts/openfoodfacts-php)
[![Average time to resolve an issue](https://isitmaintained.com/badge/resolution/openfoodfacts/openfoodfacts-php.svg)](https://isitmaintained.com/project/openfoodfacts/openfoodfacts-php "Average time to resolve an issue")
[![Percentage of issues still open](https://isitmaintained.com/badge/open/openfoodfacts/openfoodfacts-php.svg)](https://isitmaintained.com/project/openfoodfacts/openfoodfacts-php "Percentage of issues still open")

Expand Down
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"require": {
"php": ">=7.1",
"guzzlehttp/guzzle": "^6.3",
"psr/log": "^1.0"
"psr/log": "^1.0",
"psr/simple-cache": "^1.0",
"ext-json": "*",
"ext-curl": "*"
},
"autoload": {
"psr-4": {
Expand All @@ -31,6 +34,7 @@
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"symfony/cache": "^4.3",
"monolog/monolog": "^1.23",
"ext-gd": ">=7.2"
}
Expand Down
10 changes: 10 additions & 0 deletions examples/01-basic_api_usage/cached_example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
include '../../vendor/autoload.php';
$logger = new \Monolog\Logger('test');
$httpClient = new \GuzzleHttp\Client();
// the PSR-6 cache object that you want to use
$psr6Cache = new FilesystemAdapter();
$psr16Cache = new Psr16Cache($psr6Cache);
$api = new \OpenFoodFacts\Api('food', 'world', $logger, $httpClient, $psr16Cache);
$product = $api->getProduct(rand(1, 50));
$e =1;
Loading

0 comments on commit d5fc3b1

Please sign in to comment.