Skip to content

Commit fb10182

Browse files
dbuNyholm
authored andcommitted
cache-plugin is not a hard dependency to use this bundle (#311)
1 parent 8b7cb00 commit fb10182

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
1313
### Changed
1414

1515
- Removed `twig/twig` dependency
16+
- Removed hard dependency on `php-http/cache-plugin`. If you want to use the
17+
cache plugin, you need to require it in your project.
1618

1719
## 1.14.0
1820

DependencyInjection/Configuration.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Http\HttplugBundle\DependencyInjection;
44

55
use Http\Client\Common\Plugin\Cache\Generator\CacheKeyGenerator;
6+
use Http\Client\Common\Plugin\CachePlugin;
67
use Http\Client\Common\Plugin\Journal;
78
use Http\Message\CookieJar;
89
use Http\Message\Formatter;
@@ -700,7 +701,14 @@ private function createCachePluginNode()
700701
$cache = $builder->root('cache');
701702
$cache
702703
->canBeEnabled()
704+
->info('Configure HTTP caching, requires the php-http/cache-plugin package')
703705
->addDefaultsIfNotSet()
706+
->validate()
707+
->ifTrue(function ($v) {
708+
return !empty($v['enabled']) && !class_exists(CachePlugin::class);
709+
})
710+
->thenInvalid('To use the cache plugin, you need to require php-http/cache-plugin in your project')
711+
->end()
704712
->children()
705713
->scalarNode('cache_pool')
706714
->info('This must be a service id to a service implementing '.CacheItemPoolInterface::class)

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"php": "^5.5 || ^7.0",
2020
"php-http/client-common": "^1.9 || ^2.0",
2121
"php-http/client-implementation": "^1.0",
22-
"php-http/cache-plugin": "^1.6",
2322
"php-http/discovery": "^1.0",
2423
"php-http/httplug": "^1.0 || ^2.0",
2524
"php-http/logger-plugin": "^1.1",
@@ -37,6 +36,7 @@
3736
"guzzlehttp/psr7": "^1.0",
3837
"matthiasnoback/symfony-dependency-injection-test": "^1.1 || ^2.3",
3938
"nyholm/nsa": "^1.1",
39+
"php-http/cache-plugin": "^1.6",
4040
"php-http/guzzle6-adapter": "^1.1.1 || ^2.0.1",
4141
"php-http/promise": "^1.0",
4242
"php-http/mock-client": "^1.2",
@@ -57,6 +57,7 @@
5757
},
5858
"suggest": {
5959
"twig/twig": "Add this to your require-dev section when using the WebProfilerBundle",
60+
"php-http/cache-plugin": "To configure clients that cache responses",
6061
"php-http/mock-client": "Add this to your require-dev section to mock HTTP responses easily"
6162
},
6263
"autoload": {

0 commit comments

Comments
 (0)