Skip to content

Commit f976903

Browse files
committed
Merge pull request #257 from FriendsOfSymfony/adjust-php-http
Upgrade php-http integration
2 parents cb31f52 + 2459eb1 commit f976903

24 files changed

+528
-616
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ vendor/
22
composer.lock
33
phpunit.xml
44
doc/_build/
5+
puli.json
6+
.puli/

.travis.yml

Lines changed: 1 addition & 4 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
- hhvm
@@ -12,7 +11,7 @@ env:
1211

1312
matrix:
1413
include:
15-
- php: 5.4
14+
- php: 5.5
1615
env: SYMFONY_VERSION=2.3.* VARNISH_VERSION=3.0 COMPOSER_FLAGS="--prefer-lowest"
1716

1817
branches:
@@ -22,8 +21,6 @@ branches:
2221
- '/^\d+\.\d+$/'
2322

2423
install:
25-
- if [[ "$TRAVIS_PHP_VERSION" == "5.4" || "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then composer remove "php-http/guzzle6-adapter" --dev --no-update; fi
26-
- if [[ "$TRAVIS_PHP_VERSION" == "5.4" || "$TRAVIS_PHP_VERSION" == "hhvm" ]]; then composer require "php-http/guzzle5-adapter" --dev --no-update; fi
2724
- composer update $COMPOSER_FLAGS --prefer-source --no-interaction
2825

2926
before_script:

composer.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,22 @@
2020
"homepage": "https://github.com/friendsofsymfony/FOSHttpCache/contributors"
2121
}
2222
],
23+
"minimum-stability": "dev",
24+
"prefer-stable": true,
2325
"require": {
24-
"php": ">=5.4.8",
26+
"php": "^5.5.9||^7.0.0",
2527
"symfony/event-dispatcher": "^2.3||^3.0",
2628
"symfony/options-resolver": "^2.3||^3.0",
27-
"psr/http-message-implementation": "~1.0",
28-
"php-http/adapter-implementation": "^0.1.0",
29-
"php-http/discovery": "^0.1.1",
30-
"php-http/message-decorator": "^0.1.0"
29+
"php-http/client-implementation": "^1.0.0",
30+
"php-http/discovery": "^0.6.0",
31+
"php-http/message": "^0.2.1",
32+
"puli/cli": "^1.0.0-beta8"
3133
},
3234
"require-dev": {
3335
"mockery/mockery": "~0.9.1",
34-
"monolog/monolog": "~1.0",
35-
"php-http/guzzle6-adapter": "^0.1.0",
36-
"guzzlehttp/psr7": "^1.0",
36+
"monolog/monolog": "^1.0",
37+
"php-http/guzzle6-adapter": "^0.3.1",
38+
"php-http/mock-client": "~0.1",
3739
"symfony/process": "^2.3||^3.0",
3840
"symfony/http-kernel": "^2.3||^3.0"
3941
},

doc/contributing.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ The library also includes functional tests against a Varnish and NGINX instance.
3636
The functional test suite by default uses PHP’s built-in web server. If you have
3737
PHP 5.4 or newer, simply run with the default configuration.
3838

39-
If you want to run the tests on PHP 5.3, you need to configure a web server
39+
If you want to run the tests on HHVM_, you need to configure a web server
4040
listening on localhost:8080 that points to the folder
41-
``tests/Functional/Fixtures/web``.
42-
43-
If you want to run the tests on HHVM_, you need to configure a web server and
44-
start a `HHVM FastCGI server`_.
41+
``tests/Functional/Fixtures/web`` and start a `HHVM FastCGI server`_.
4542

4643
To run the functional tests:
4744

doc/installation.rst

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,20 @@ Installation
55
------------
66

77
The FOSHttpCache library is available on Packagist_. You can install it using
8-
Composer_:
8+
Composer_.
99

10-
.. code-block:: bash
10+
The library relies on HTTPlug_ for sending invalidation requests over HTTP, so
11+
you need to install an HTTPlug-compatible client or adapter first:
1112

12-
$ composer require friendsofsymfony/http-cache
13+
.. code-block:: bash
1314
14-
Note that the library needs a ``psr/http-message-implementation`` and
15-
``php-http/adapter-implementation``. If your project does not contain one,
16-
composer will complain that it did not find ``psr/http-message-implementation``.
15+
$ composer require php-http/guzzle6-adapter
1716
18-
When on PHP 5.5+, use the following line instead:
17+
Then install the FOSHttpCache library itself:
1918

2019
.. code-block:: bash
2120
22-
$ composer require friendsofsymfony/http-cache guzzlehttp/psr7:^1.0 php-http/guzzle6-adapter:^0.1.0
23-
24-
On PHP 5.4, the ``php-http/guzzle5-adapter:^0.1.0`` works fine.
21+
$ composer require friendsofsymfony/http-cache
2522
2623
.. note::
2724

@@ -61,3 +58,4 @@ invalidation requests:
6158
.. _Packagist: https://packagist.org/packages/friendsofsymfony/http-cache
6259
.. _Composer: http://getcomposer.org
6360
.. _Semantic Versioning: http://semver.org/
61+
.. _HTTPlug: http://httplug.io

doc/proxy-clients.rst

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ which caching solution you use.
1212
Setup
1313
-----
1414

15-
HTTP Adapter Installation
16-
~~~~~~~~~~~~~~~~~~~~~~~~~
15+
HTTP Client Installation
16+
~~~~~~~~~~~~~~~~~~~~~~~~
1717

18-
Because the clients send invalidation requests over HTTP, an `HTTP adapter`_
19-
must be installed. Which one you need depends on the HTTP client library that
20-
you use in your project. For instance, if you use Guzzle 6 in your project,
21-
install the appropriate adapter:
18+
Because the clients send invalidation requests over HTTP, an `HTTPlug client`_
19+
must be installed. Pick either a standalone client or an adapter to a client
20+
library that is already included in your project. For instance, if you use
21+
Guzzle 6 in your project, install the appropriate adapter:
2222

2323
.. code-block:: bash
2424
2525
$ composer require php-http/guzzle6-adapter
2626
2727
You also need a `PSR-7 message implementation`_. If you use Guzzle 6, Guzzle’s
28-
implementation is already included. If you use another client, install one of
29-
the implementations. Recommended:
28+
implementation is already included. If you use another client, you need to
29+
install one of the message implementations. Recommended:
3030

3131
.. code-block:: bash
3232
@@ -40,13 +40,13 @@ Alternatively:
4040
4141
.. _HTTP adapter configuration:
4242

43-
HTTP Adapter Configuration
44-
~~~~~~~~~~~~~~~~~~~~~~~~~~
43+
HTTP Client Configuration
44+
~~~~~~~~~~~~~~~~~~~~~~~~~
4545

46-
By default, the proxy client will find the adapter that you have installed
47-
through Composer. But you can also pass the adapter explicitly. This is most
48-
useful when you have created a HTTP client with custom options or middleware
49-
(such as logging)::
46+
By default, the proxy client will automatically locate an HTTP client that you
47+
have installed through Composer. But you can also pass the adapter explicitly.
48+
This is most useful when you have created a HTTP client with custom options or
49+
middleware (such as logging)::
5050

5151
use GuzzleHttp\Client;
5252

@@ -66,6 +66,13 @@ Then pass that adapter to the caching proxy client::
6666
$proxyClient = new Varnish($servers, '/baseUrl', $adapter);
6767
// Varnish as example, but also possible for NGINX and Symfony
6868

69+
HTTP Message Factory Configuration
70+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71+
72+
Similar to the HTTP client, the HTTP message factory is automatically located
73+
by default. You can pass an explicit instance of the message factory if you
74+
need to.
75+
6976
.. _varnish client:
7077

7178
Varnish Client
@@ -276,6 +283,5 @@ Varnish client::
276283
Make sure to add any headers that you want to ban on to your
277284
:doc:`proxy configuration <proxy-configuration>`.
278285

279-
.. _header: http://php.net/header
280-
.. _HTTP Adapter: http://php-http.readthedocs.org/en/latest/
286+
.. _HTTPlug client: http://httplug.io/
281287
.. _PSR-7 message implementation: https://packagist.org/providers/psr/http-message-implementation

src/Exception/ProxyUnreachableException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace FOS\HttpCache\Exception;
1313

14-
use Http\Adapter\Exception\HttpAdapterException;
14+
use Http\Client\Exception\RequestException;
1515

1616
/**
1717
* Thrown when a request to the reverse caching proxy fails to establish a
@@ -20,18 +20,18 @@
2020
class ProxyUnreachableException extends \RuntimeException implements HttpCacheExceptionInterface
2121
{
2222
/**
23-
* @param HttpAdapterException $adapterException
23+
* @param RequestException $adapterException
2424
*
2525
* @return ProxyUnreachableException
2626
*/
27-
public static function proxyUnreachable(HttpAdapterException $adapterException)
27+
public static function proxyUnreachable(RequestException $adapterException)
2828
{
2929
$message = sprintf(
3030
'Request to caching proxy at %s failed with message "%s"',
3131
$adapterException->getRequest()->getHeaderLine('Host'),
3232
$adapterException->getMessage()
3333
);
34-
34+
3535
return new ProxyUnreachableException(
3636
$message,
3737
0,

0 commit comments

Comments
 (0)