File tree Expand file tree Collapse file tree 3 files changed +325
-232
lines changed
Expand file tree Collapse file tree 3 files changed +325
-232
lines changed Original file line number Diff line number Diff line change 11<?php
22
3- use GuzzleHttp \Subscriber \Cache \CacheSubscriber ;
3+ use GuzzleHttp \Client ;
4+ use GuzzleHttp \HandlerStack ;
5+ use Kevinrob \GuzzleCache \CacheMiddleware ;
6+ use Doctrine \Common \Cache \FilesystemCache ;
7+ use Kevinrob \GuzzleCache \Strategy \PrivateCacheStrategy ;
8+ use Kevinrob \GuzzleCache \Storage \DoctrineCacheStorage ;
49
510require __DIR__ . '/vendor/autoload.php ' ;
611
712date_default_timezone_set ('UTC ' );
813
914$ results = array ();
1015
11- $ client = new \GuzzleHttp \Client ();
12- $ storage = new \GuzzleHttp \Subscriber \Cache \CacheStorage (new \Doctrine \Common \Cache \FilesystemCache (__DIR__ . '/cache ' ));
13- CacheSubscriber::attach ($ client , ['storage ' => $ storage ]);
16+ $ stack = HandlerStack::create ();
17+ $ stack ->push (
18+ new CacheMiddleware (
19+ new PrivateCacheStrategy (
20+ new DoctrineCacheStorage (
21+ new FilesystemCache (__DIR__ . '/cache ' )
22+ )
23+ )
24+ ),
25+ 'cache '
26+ );
27+ $ client = new Client (['handler ' => $ stack ]);
1428
1529$ data = json_decode ($ client ->get ('https://www.drupal.org/api-d7/node.json?type=project_release&taxonomy_vocabulary_7=100&field_release_build_type=static ' )->getBody ());
1630
Original file line number Diff line number Diff line change 77 }
88 ],
99 "require" : {
10- "guzzlehttp/guzzle" : " 5.3.0" ,
11- "guzzlehttp/cache-subscriber" : " 0.1.*@dev" ,
12- "composer/composer" : " ^1.0"
10+ "composer/composer" : " ^1.0" ,
11+ "kevinrob/guzzle-cache-middleware" : " ^3.2" ,
12+ "guzzlehttp/guzzle" : " ^6.3" ,
13+ "doctrine/cache" : " ^1.7"
1314 }
1415}
You can’t perform that action at this time.
0 commit comments