From ae5ddddd1364b112c77a440f7755a3110cd374ae Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Tue, 26 Jun 2018 12:15:06 +0100 Subject: [PATCH 01/10] Bump guzzle-services to >v1.0, drop PHP 5.4 support, support SF3+SF4 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index adb5a80..5210189 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,9 @@ } ], "require": { - "php": ">=5.4.0", - "symfony/framework-bundle": "2.*", - "guzzlehttp/guzzle-services": "~0.1" + "php": ">=5.5", + "symfony/framework-bundle": "^2.0|^3.0|^4.0", + "guzzlehttp/guzzle-services": "^1.0" }, "require-dev": { "symfony/browser-kit": "~2.5", From a63cc845d481899cf79f5ddc23c195297f17653c Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Tue, 26 Jun 2018 12:20:58 +0100 Subject: [PATCH 02/10] Allow browser-kit SF3+SF4 versions --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5210189..3ed014c 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "guzzlehttp/guzzle-services": "^1.0" }, "require-dev": { - "symfony/browser-kit": "~2.5", + "symfony/browser-kit": "~2.5|^3.0|^4.0", "phpunit/phpunit": "~4.7", "squizlabs/php_codesniffer": "~1.5", "phpmd/phpmd": "~2.0", From c2b381e9d3f15e7743c33c2cd644b80d0276fa08 Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Tue, 26 Jun 2018 12:24:52 +0100 Subject: [PATCH 03/10] Remove SF2 support --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 3ed014c..f62b664 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "boxuk/postcodes-io-bundle", "type": "library", - "description": "A Symfony2 bundle for interaction with the postcodes.io service.", + "description": "A Symfony 3/4 bundle for interaction with the postcodes.io service.", "keywords": ["postcode", "postcodes.io", "guzzle"], "license": "MIT", "authors": [ @@ -11,12 +11,12 @@ } ], "require": { - "php": ">=5.5", - "symfony/framework-bundle": "^2.0|^3.0|^4.0", + "php": "^7.0", + "symfony/framework-bundle": "^3.0|^4.0", "guzzlehttp/guzzle-services": "^1.0" }, "require-dev": { - "symfony/browser-kit": "~2.5|^3.0|^4.0", + "symfony/browser-kit": "^3.0|^4.0", "phpunit/phpunit": "~4.7", "squizlabs/php_codesniffer": "~1.5", "phpmd/phpmd": "~2.0", From 308fe62135c8de0bc7080cbd466d98ba9ea2f9a1 Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Tue, 26 Jun 2018 12:39:30 +0100 Subject: [PATCH 04/10] Update factory service syntax --- Resources/config/services.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/config/services.xml b/Resources/config/services.xml index b92d553..9e8a21a 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -10,8 +10,8 @@ - - + + %box_uk_postcodes_io.base_url% From eeb6ef9b3bc0f6bffdc3527c974d98c4afa841fe Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Tue, 26 Jun 2018 13:47:27 +0100 Subject: [PATCH 05/10] Create ApiClient.php --- Api/ApiClient.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Api/ApiClient.php diff --git a/Api/ApiClient.php b/Api/ApiClient.php new file mode 100644 index 0000000..e933372 --- /dev/null +++ b/Api/ApiClient.php @@ -0,0 +1,22 @@ + '']) + * @method array bulkLookup(array $parameters = ['postcodes' => []]) + * @method array reverseGeocode(array $parameters = ['longitude' => '', 'latitude' => '', 'limit' => '', 'radius' => '']) + * @method array bulkReverseGeocode(array $parameters = []) + * @method array matching(array $parameters = ['query' => '', 'limit' => '']) + * @method array validate(array $parameters = ['postcode' => '']) + * @method array autocomplete(array $parameters = ['postcode' => '', 'limit' => '']) + * @method array random() + * @method array outwardCodeLookup(array $parameters = ['postcode' => '']) + */ +class ApiClient extends GuzzleClient +{ +} From d30ac167f0f97f970a22cbd4e3a3e4f5eab950fa Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Tue, 26 Jun 2018 13:48:13 +0100 Subject: [PATCH 06/10] Return instance of skeleton ApiClient --- Api/ClientFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Api/ClientFactory.php b/Api/ClientFactory.php index 3f0cc68..19a8ea9 100644 --- a/Api/ClientFactory.php +++ b/Api/ClientFactory.php @@ -25,7 +25,7 @@ class ClientFactory */ public function create($baseUrl = self::DEFAULT_BASE_URL) { - return new GuzzleClient(new Client(), $this->getServiceDescription($baseUrl)); + return new ApiClient(new Client(), $this->getServiceDescription($baseUrl)); } /** From 52ccc78e73ff4ca05716773a6a9c57523856dd96 Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Tue, 26 Jun 2018 13:49:00 +0100 Subject: [PATCH 07/10] Use FQCNs instead of period-separated service names in definitions --- Resources/config/services.xml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 9e8a21a..2554af0 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -4,14 +4,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - - BoxUk\PostcodesIoBundle\Api\ClientFactory - GuzzleHttp\Command\Guzzle\GuzzleClient - - - - + + + %box_uk_postcodes_io.base_url% From ec0ef52c18aea434cbbff966f4f78ab7133774f8 Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Tue, 26 Jun 2018 13:49:50 +0100 Subject: [PATCH 08/10] Test on > PHP 7 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd9b6b3..8641136 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: php php: - - 5.4 - - 5.5 - - 5.6 + - 7.0 + - 7.1 + - 7.2 branches: only: From 48a67c4eed1e838a3ca2c2de19c04aeac5451282 Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Thu, 28 Jun 2018 14:55:49 +0100 Subject: [PATCH 09/10] Guzzle v1 renamed "postField" location to "formParam" --- Api/ClientFactory.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Api/ClientFactory.php b/Api/ClientFactory.php index 19a8ea9..6b0fa40 100644 --- a/Api/ClientFactory.php +++ b/Api/ClientFactory.php @@ -59,7 +59,7 @@ protected function getServiceDescription($baseUrl) 'responseModel' => 'getResponse', 'parameters' => array( 'postcodes' => array( - 'location' => 'postField', + 'location' => 'formParam', 'description' => 'The postcodes to look up (max 100).', 'required' => true ) @@ -98,7 +98,7 @@ protected function getServiceDescription($baseUrl) 'responseModel' => 'getResponse', 'parameters' => array( 'geolocations' => array( - 'location' => 'postField', + 'location' => 'formParam', 'description' => 'The latitude and longitude coordinates to look up.', 'required' => true ) From 6f5216a091ef46105a5726dcf723d894560b1902 Mon Sep 17 00:00:00 2001 From: Dan Abrey Date: Thu, 28 Jun 2018 14:57:01 +0100 Subject: [PATCH 10/10] Add note RE tests failing --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 41be95d..f317c31 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ A bundle for querying the [postcodes.io](http://postcodes.io) web service. [License](LICENSE) +Note from DailyInfo - SF4 work in progress +==== + +This is a fork of the excellent [Symfony 2 bundle by Chris Collins of Box UK](https://github.com/boxuk/postcodes-io-bundle) that has been updated to support Symfony 3/4. The tests are failing due to the updated version of Guzzle being used in this fork, use it at your own risk. The version of Guzzle has been updated to v6, which means that the mocking of clients must be changed - if you find yourself using this fork and have Guzzle testing experience, please feel free to submit a pull request. Installation ------------