diff --git a/CHANGELOG.md b/CHANGELOG.md index 0206a44d..148875ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee ### Changed - Removed `twig/twig` dependency +- Removed hard dependency on `php-http/cache-plugin`. If you want to use the + cache plugin, you need to require it in your project. ## 1.14.0 diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 3e898067..63a3e3b4 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -3,6 +3,7 @@ namespace Http\HttplugBundle\DependencyInjection; use Http\Client\Common\Plugin\Cache\Generator\CacheKeyGenerator; +use Http\Client\Common\Plugin\CachePlugin; use Http\Client\Common\Plugin\Journal; use Http\Message\CookieJar; use Http\Message\Formatter; @@ -700,7 +701,14 @@ private function createCachePluginNode() $cache = $builder->root('cache'); $cache ->canBeEnabled() + ->info('Configure HTTP caching, requires the php-http/cache-plugin package') ->addDefaultsIfNotSet() + ->validate() + ->ifTrue(function ($v) { + return !empty($v['enabled']) && !class_exists(CachePlugin::class); + }) + ->thenInvalid('To use the cache plugin, you need to require php-http/cache-plugin in your project') + ->end() ->children() ->scalarNode('cache_pool') ->info('This must be a service id to a service implementing '.CacheItemPoolInterface::class) diff --git a/composer.json b/composer.json index 8224c022..3691afee 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,6 @@ "php": "^5.5 || ^7.0", "php-http/client-common": "^1.9 || ^2.0", "php-http/client-implementation": "^1.0", - "php-http/cache-plugin": "^1.6", "php-http/discovery": "^1.0", "php-http/httplug": "^1.0 || ^2.0", "php-http/logger-plugin": "^1.1", @@ -37,6 +36,7 @@ "guzzlehttp/psr7": "^1.0", "matthiasnoback/symfony-dependency-injection-test": "^1.1 || ^2.3", "nyholm/nsa": "^1.1", + "php-http/cache-plugin": "^1.6", "php-http/guzzle6-adapter": "^1.1.1 || ^2.0.1", "php-http/promise": "^1.0", "php-http/mock-client": "^1.2", @@ -57,6 +57,7 @@ }, "suggest": { "twig/twig": "Add this to your require-dev section when using the WebProfilerBundle", + "php-http/cache-plugin": "To configure clients that cache responses", "php-http/mock-client": "Add this to your require-dev section to mock HTTP responses easily" }, "autoload": {