Skip to content

Commit e64c088

Browse files
committed
continued refactoring
1 parent 76091d4 commit e64c088

File tree

14 files changed

+46
-730
lines changed

14 files changed

+46
-730
lines changed

.travis.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: php
22

33
php:
4-
- 5.4
54
- 5.5
65
- 5.6
76
- 7.0
@@ -20,14 +19,6 @@ matrix:
2019
- COVERAGE=true
2120
- php: 5.6
2221
env: SYMFONY_VERSION='2.3.*'
23-
- php: 5.6
24-
env:
25-
- SYMFONY_VERSION='2.4.*'
26-
- FRAMEWORK_EXTRA_VERSION='~3.0'
27-
- php: 5.6
28-
env:
29-
- SYMFONY_VERSION='2.5.*'
30-
- FRAMEWORK_EXTRA_VERSION='~3.0'
3122
- php: 5.6
3223
env:
3324
- SYMFONY_VERSION='2.6.*'
@@ -40,16 +31,14 @@ matrix:
4031
env:
4132
- SYMFONY_VERSION='2.8.*@dev'
4233
- FRAMEWORK_EXTRA_VERSION='~3.0'
43-
- php: 5.4
34+
- php: 5.5
4435
env:
4536
- SYMFONY_VERSION=2.3.*
4637
- COMPOSER_FLAGS="--prefer-lowest"
4738

4839
before_script:
4940
- sh -c 'if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update symfony/symfony=$SYMFONY_VERSION; fi;'
5041
- sh -c 'if [ "$FRAMEWORK_EXTRA_VERSION" != "" ]; then composer require --dev --no-update sensio/framework-extra-bundle=$FRAMEWORK_EXTRA_VERSION; fi;'
51-
- if [[ "$TRAVIS_PHP_VERSION" == "5.4" || "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then composer remove "php-http/guzzle6-adapter" --dev --no-update; fi
52-
- if [[ "$TRAVIS_PHP_VERSION" == "5.4" || "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then composer require "php-http/guzzle5-adapter" --dev --no-update; fi
5342
- composer update $COMPOSER_FLAGS --no-interaction
5443
- sudo apt-get install python-sphinx enchant
5544
- sudo pip install -r Resources/doc/requirements.txt

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ Changelog
77
* Updated the version of FOSHttpCache to 2.*. See [FOSHttpCache changelog]
88
(https://github.com/FriendsOfSymfony/FOSHttpCache/blob/master/CHANGELOG.md).
99
Most important, there is no more hard coupling on Guzzle HTTP client. We now
10-
use the HTTP adapter. You now need to explicitly specify the adapter you
11-
want, see [installation instructions]
10+
use the HTTPlug HTTP client abstraction. You now need to explicitly specify
11+
the adapter you want, see [installation instructions]
1212
(http://foshttpcachebundle.readthedocs.org/en/stable/installation.html)
13+
Deprecated methods have been removed.
1314

1415
1.3.2
1516
-----

DependencyInjection/Configuration.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode)
325325
->defaultNull()
326326
->info('Default host name and optional path for path based invalidation.')
327327
->end()
328-
->scalarNode('guzzle_client')
329-
->defaultNull()
330-
->info('Guzzle service to use for customizing the requests.')
328+
->scalarNode('http_client')
329+
->defaultValue('httplug.client')
330+
->info('Httplug service to use for sending the requests.')
331331
->end()
332332
->end()
333333
->end()
@@ -347,9 +347,9 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode)
347347
->defaultNull()
348348
->info('Default host name and optional path for path based invalidation.')
349349
->end()
350-
->scalarNode('guzzle_client')
351-
->defaultNull()
352-
->info('Guzzle service to use for customizing the requests.')
350+
->scalarNode('http_client')
351+
->defaultValue('httplug.client')
352+
->info('Httplug service to use for sending the requests.')
353353
->end()
354354
->scalarNode('purge_location')
355355
->defaultValue('')
@@ -373,9 +373,9 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode)
373373
->defaultNull()
374374
->info('Default host name and optional path for path based invalidation.')
375375
->end()
376-
->scalarNode('guzzle_client')
377-
->defaultNull()
378-
->info('Guzzle service to use for customizing the requests.')
376+
->scalarNode('http_client')
377+
->defaultValue('httplug.client')
378+
->info('httplug service to use for sending the requests.')
379379
->end()
380380
->end()
381381
->end()

DependencyInjection/FOSHttpCacheExtension.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader,
255255
}
256256
$container->setParameter($this->getAlias().'.proxy_client.varnish.servers', $config['servers']);
257257
$container->setParameter($this->getAlias().'.proxy_client.varnish.base_url', $baseUrl);
258-
if (!empty($config['guzzle_client'])) {
259-
$container->setParameter($this->getAlias().'.proxy_client.varnish.guzzle_client', $config['guzzle_client']);
260-
}
258+
$container->setParameter($this->getAlias().'.proxy_client.varnish.http_client', $config['http_client']);
261259
}
262260

263261
private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, array $config)
@@ -274,9 +272,7 @@ private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, a
274272
$container->setParameter($this->getAlias().'.proxy_client.nginx.servers', $config['servers']);
275273
$container->setParameter($this->getAlias().'.proxy_client.nginx.base_url', $baseUrl);
276274
$container->setParameter($this->getAlias().'.proxy_client.nginx.purge_location', $config['purge_location']);
277-
if (!empty($config['guzzle_client'])) {
278-
$container->setParameter($this->getAlias().'.proxy_client.nginx.guzzle_client', $config['guzzle_client']);
279-
}
275+
$container->setParameter($this->getAlias().'.proxy_client.nginx.http_client', $config['http_client']);
280276
}
281277

282278
private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, array $config)
@@ -293,9 +289,7 @@ private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader,
293289
}
294290
$container->setParameter($this->getAlias().'.proxy_client.symfony.servers', $config['servers']);
295291
$container->setParameter($this->getAlias().'.proxy_client.symfony.base_url', $baseUrl);
296-
if (!empty($config['guzzle_client'])) {
297-
$container->setParameter($this->getAlias().'.proxy_client.symfony.guzzle_client', $config['guzzle_client']);
298-
}
292+
$container->setParameter($this->getAlias().'.proxy_client.symfony.http_client', $config['http_client']);
299293
}
300294

301295
private function loadCacheTagging(ContainerBuilder $container, XmlFileLoader $loader, array $config, $client)
@@ -327,7 +321,6 @@ private function loadTest(ContainerBuilder $container, XmlFileLoader $loader, ar
327321

328322
if (isset($config['client']['varnish']['enabled'])
329323
|| isset($config['client']['nginx']['enabled'])) {
330-
$loader->load('test_client.xml');
331324

332325
if ($config['client']['varnish']['enabled']) {
333326
$loader->load('varnish_test_client.xml');

HttpCache.php

Lines changed: 0 additions & 108 deletions
This file was deleted.

Resources/config/test_client.xml

Lines changed: 0 additions & 26 deletions
This file was deleted.

Resources/config/varnish_test_client.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
<services>
88
<service id="fos_http_cache.test.client.varnish"
9-
parent="fos_http_cache.test.client.abstract">
10-
<argument index="0">%fos_http_cache.proxy_client.varnish.base_url%</argument>
9+
class="Http\Utils\HttpMethodsClient">
10+
<argument id="%fos_http_cache.proxy_client.varnish.http_client%" type="service"/>
11+
<argument type="collection"/> <!-- setup options like base_url
12+
<argument index="0">%fos_http_cache.proxy_client.varnish.base_url%</argument>
13+
-->
1114
</service>
1215
</services>
1316

Resources/doc/features/invalidation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ To refresh paths and routes, you can use ``refreshPath($path, $headers)`` and
6363

6464
If you want to add a header (such as ``Authorization``) to *all*
6565
invalidation requests, you can use a
66-
:ref:`custom Guzzle client <custom guzzle client>` instead.
66+
:ref:`custom HTTP client <custom HTTP client>` instead.
6767

6868
.. _invalidation configuration:
6969

Resources/doc/overview.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ This bundle is available on Packagist_. You can install it using Composer:
1111
$ composer require friendsofsymfony/http-cache-bundle
1212
1313
Note that the FOSHttpCache_ library needs a ``psr/http-message-implementation``
14-
and ``php-http/adapter-implementation``. If your project does not contain one,
15-
composer will complain that it did not find ``psr/http-message-implementation``.
16-
17-
When on PHP 5.5+, use the following line instead:
14+
and ``php-http/client-implementation``. If your project does not contain one,
15+
composer will complain that it did not find ``psr/http-message-implementation``:
1816

1917
.. code-block:: bash
2018
21-
$ composer require friendsofsymfony/http-cache-bundle:~2.0 guzzlehttp/psr7:^1.0 php-http/guzzle6-adapter:^0.1.0
19+
$ composer require friendsofsymfony/http-cache-bundle:~2.0 guzzlehttp/psr7:^1.0 php-http/guzzle6-adapter:^1.0.0
2220
23-
On PHP 5.4, the ``php-http/guzzle5-adapter:^0.1.0`` works fine.
21+
If you want to use something else than Guzzle 6, see packagist
22+
for a list of available `client implementations`_.
2423

2524
Then add the bundle to your application:
2625

@@ -115,3 +114,4 @@ This bundle is released under the MIT license.
115114
.. _SensioFrameworkExtraBundle: http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/index.html
116115
.. _ExpressionLanguage: http://symfony.com/doc/current/components/expression_language/introduction.html
117116
.. _Symfony: http://symfony.com/doc/current/book/http_cache.html#the-cache-control-header
117+
.. _client implementations: https://packagist.org/providers/php-http/client-implementation

Resources/doc/reference/configuration/proxy-client.rst

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,14 @@ The default proxy client that will be used by the cache manager. You can
126126
*configure Nginx, Varnish and Symfony proxy clients in parallel*. There is
127127
however only one cache manager and it will only use the default client.
128128

129-
Custom Guzzle Client
130-
--------------------
131-
132-
By default, the proxy client instantiates a `Guzzle client`_ to talk with the
133-
caching proxy. If you need to customize the requests, for example to send a
134-
basic authentication header, you can configure a service and specify that in
135-
the ``guzzle_client`` option of any of the cache proxy clients. A sample
136-
service definition for using basic authentication looks like this:
137-
138-
.. code-block:: yaml
139-
140-
# app/config/config.yml
141-
acme.varnish.guzzle.client:
142-
class: Guzzle\Service\Client
143-
calls:
144-
- [setDefaultOption, [auth, [%caching_proxy.username%, %caching_proxy.password%, basic ]]]
129+
Custom HTTP Client
130+
------------------
131+
132+
The proxy client uses a ``Http\Client\Utils\HttpMethodsClient`` wrapping a
133+
``Http\Client\HttpClient`` instance. If you need to customize the requests, for
134+
example to send a basic authentication header with each request, you can
135+
configure a service for the ``HttpClient`` and specify that in the
136+
``http_client`` option of any of the cache proxy clients.
145137

146138
Caching Proxy Configuration
147139
---------------------------

0 commit comments

Comments
 (0)