Skip to content

cache-plugin is not a hard dependency to use this bundle #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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": {
Expand Down