launchdarkly/php-server-sdk

Error: Class 'Kevinrob\GuzzleCache\CacheMiddleware' not found

bradynpoulsen opened this issue · 4 comments

Reproduction Steps

  1. Install via Composer
$ composer require launchdarkly/launchdarkly-php
  1. Construct an instance of the LDClient
$client = new LaunchDarkly\LDClient('sdk-...');

Expected Outcome

LaunchDarkly\GuzzleFeatureRequester will try to utilize the Kevinrob\GuzzleCache\CacheMiddleware class if the class is available

Actual Outcome

Error: Class 'Kevinrob\GuzzleCache\CacheMiddleware' not found

Proposed Resolution

Allow for utilization of the GuzzleFeatureRequester without requiring a 3rd party caching handler in scenarios that Kevinrob\GuzzleCache\CacheMiddleware is not suitable (ie, single run containers that discard their filesystem and memory after use)

  1. Modify LaunchDarkly\GuzzleFeatureRequester to utilize Kevinrob\GuzzleCache\CacheMiddleware if it is available via class_exists
  2. Add a message to the kevinrob/guzzle-cache-middleware composer.json suggestion describing its role in the library

The documentation leads ones to believe that KevinRob is an optional dependency but in practice it must be manually added to composer. It shows in the 'Using Guzzle' section. Maybe what's happening is that if Guzzle if found (cause it's part of another dependency) then LD assumes KevinRob is available.

The KevinRob cache is only in memory unless you configure the LDClient's "cache" option. That is only useful if you are making multiple http calls though.. Perhaps another option is to only try to utilize KevinRob if the cache option is configured

@bradynpoulsen how do the changes in #78 look to you?

The changes were released in 2.1.2.