Skip to content

Commit f996d78

Browse files
committed
continued refactoring
1 parent 0c8c4fd commit f996d78

File tree

13 files changed

+45
-733
lines changed

13 files changed

+45
-733
lines changed

CHANGELOG.md

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

2021
1.3.7
2122
-----

DependencyInjection/Configuration.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode)
333333
->defaultNull()
334334
->info('Default host name and optional path for path based invalidation.')
335335
->end()
336-
->scalarNode('guzzle_client')
337-
->defaultNull()
338-
->info('Guzzle service to use for customizing the requests.')
336+
->scalarNode('http_client')
337+
->defaultValue('httplug.client')
338+
->info('Httplug service to use for sending the requests.')
339339
->end()
340340
->end()
341341
->end()
@@ -357,9 +357,9 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode)
357357
->defaultNull()
358358
->info('Default host name and optional path for path based invalidation.')
359359
->end()
360-
->scalarNode('guzzle_client')
361-
->defaultNull()
362-
->info('Guzzle service to use for customizing the requests.')
360+
->scalarNode('http_client')
361+
->defaultValue('httplug.client')
362+
->info('Httplug service to use for sending the requests.')
363363
->end()
364364
->scalarNode('purge_location')
365365
->defaultValue('')
@@ -385,9 +385,9 @@ private function addProxyClientSection(ArrayNodeDefinition $rootNode)
385385
->defaultNull()
386386
->info('Default host name and optional path for path based invalidation.')
387387
->end()
388-
->scalarNode('guzzle_client')
389-
->defaultNull()
390-
->info('Guzzle service to use for customizing the requests.')
388+
->scalarNode('http_client')
389+
->defaultValue('httplug.client')
390+
->info('httplug service to use for sending the requests.')
391391
->end()
392392
->end()
393393
->end()

DependencyInjection/FOSHttpCacheExtension.php

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,7 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader,
273273
}
274274
$container->setParameter($this->getAlias().'.proxy_client.varnish.servers', $config['servers']);
275275
$container->setParameter($this->getAlias().'.proxy_client.varnish.base_url', $baseUrl);
276-
277-
if (!empty($config['guzzle_client'])) {
278-
$container->setAlias(
279-
$this->getAlias().'.proxy_client.varnish.guzzle_client',
280-
$config['guzzle_client']
281-
);
282-
}
276+
$container->setParameter($this->getAlias().'.proxy_client.varnish.http_client', $config['http_client']);
283277
}
284278

285279
private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, array $config)
@@ -296,13 +290,7 @@ private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, a
296290
$container->setParameter($this->getAlias().'.proxy_client.nginx.servers', $config['servers']);
297291
$container->setParameter($this->getAlias().'.proxy_client.nginx.base_url', $baseUrl);
298292
$container->setParameter($this->getAlias().'.proxy_client.nginx.purge_location', $config['purge_location']);
299-
300-
if (!empty($config['guzzle_client'])) {
301-
$container->setAlias(
302-
$this->getAlias().'.proxy_client.nginx.guzzle_client',
303-
$config['guzzle_client']
304-
);
305-
}
293+
$container->setParameter($this->getAlias().'.proxy_client.nginx.http_client', $config['http_client']);
306294
}
307295

308296
private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, array $config)
@@ -319,13 +307,7 @@ private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader,
319307
}
320308
$container->setParameter($this->getAlias().'.proxy_client.symfony.servers', $config['servers']);
321309
$container->setParameter($this->getAlias().'.proxy_client.symfony.base_url', $baseUrl);
322-
323-
if (!empty($config['guzzle_client'])) {
324-
$container->setAlias(
325-
$this->getAlias().'.proxy_client.symfony.guzzle_client',
326-
$config['guzzle_client']
327-
);
328-
}
310+
$container->setParameter($this->getAlias().'.proxy_client.symfony.http_client', $config['http_client']);
329311
}
330312

331313
/**
@@ -372,7 +354,6 @@ private function loadTest(ContainerBuilder $container, XmlFileLoader $loader, ar
372354

373355
if (isset($config['client']['varnish']['enabled'])
374356
|| isset($config['client']['nginx']['enabled'])) {
375-
$loader->load('test_client.xml');
376357

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

HttpCache.php

Lines changed: 0 additions & 107 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)