diff --git a/composer.json b/composer.json index 8384843e..48f76106 100644 --- a/composer.json +++ b/composer.json @@ -33,12 +33,13 @@ "geocoder-php/google-maps-provider": "^4.7.0", "geocoder-php/nominatim-provider": "^5.7", "geocoder-php/provider-implementation": "^1.0", - "php-http/cakephp-adapter": "^0.4.0", "php-http/discovery": "^1.18.0", - "php-http/message": "^1.8.0", + "php-http/message": "^1.16.0", + "geocoder-php/common-http": "^4.6.0", "phpunit/phpunit": "^10.1", "psr/http-message": "2.0.x-dev as 1.0.0", - "willdurand/geocoder": "^4.6.0" + "willdurand/geocoder": "^4.6.0", + "symfony/http-client": "^6.0 || ^7.0" }, "minimum-stability": "stable", "prefer-stable": true, @@ -60,6 +61,9 @@ "php-http/discovery": true } }, + "conflict": { + "php-http/cakephp-adapter": "*" + }, "scripts": { "cs-check": "phpcs --extensions=php", "cs-fix": "phpcbf --extensions=php", diff --git a/docs/Install.md b/docs/Install.md index 7ddaba0e..0d4c3cfa 100644 --- a/docs/Install.md +++ b/docs/Install.md @@ -39,13 +39,6 @@ Plugin::loadAll([ ## Optional packages Depending on what tools you use (e.g. geocoding), you might need additional packages. -So depending on the type of engine/adapter, you might need for example the following for geocoding: - - "php-http/cakephp-adapter": "^0.3.0", - "php-http/message": "^1.8.0", - -Add this to your composer.json require section then. - For using GoogleMaps as concrete adapter, you might also need for example: "geocoder-php/provider-implementation": "^1.0", diff --git a/src/Geocoder/Geocoder.php b/src/Geocoder/Geocoder.php index 281bff03..b9218280 100644 --- a/src/Geocoder/Geocoder.php +++ b/src/Geocoder/Geocoder.php @@ -4,7 +4,7 @@ use Cake\Core\Configure; use Cake\Core\InstanceConfigTrait; -use Cake\Http\Client as HttpCakeClient; +use Cake\Http\Client; use Cake\I18n\I18n; use Geo\Exception\InconclusiveException; use Geo\Exception\NotAccurateEnoughException; @@ -15,7 +15,6 @@ use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; use Geocoder\StatefulGeocoder; -use Http\Adapter\Cake\Client; use Locale; /** @@ -129,7 +128,7 @@ class Geocoder { protected $geocoder; /** - * @var \Http\Client\HttpClient + * @var \Cake\Http\Client */ protected $adapter; @@ -354,9 +353,9 @@ protected function _buildGeocoder() { return; } - /** @var \Http\Client\HttpClient $adapterClass */ + /** @var \Cake\Http\Client $adapterClass */ $adapterClass = $this->getConfig('adapter'); - $this->adapter = new $adapterClass(new HttpCakeClient(), new ResponseFactory()); + $this->adapter = new $adapterClass(new Client(), new ResponseFactory()); $provider = new GoogleMaps($this->adapter, $this->getConfig('region'), $this->getConfig('apiKey')); $geocoder = new StatefulGeocoder($provider, $this->getConfig('locale') ?: 'en'); diff --git a/src/Geocoder/Provider/GeoIpLookup.php b/src/Geocoder/Provider/GeoIpLookup.php index 3887c5bd..dafc6949 100644 --- a/src/Geocoder/Provider/GeoIpLookup.php +++ b/src/Geocoder/Provider/GeoIpLookup.php @@ -6,6 +6,7 @@ namespace Geo\Geocoder\Provider; +use Cake\Http\Client; use Cake\Utility\Xml; use Geocoder\Collection; use Geocoder\Exception\InvalidServerResponse; @@ -16,7 +17,6 @@ use Geocoder\Model\AdminLevel; use Geocoder\Query\GeocodeQuery; use Geocoder\Query\ReverseQuery; -use Http\Client\HttpClient; /** * @author Mark Scherer @@ -39,11 +39,11 @@ class GeoIpLookup extends AbstractHttpProvider { protected $referer; /** - * @param \Http\Client\HttpClient $client an HTTP client + * @param \Cake\Http\Client $client an HTTP client * @param string $userAgent Value of the User-Agent header * @param string $referer Value of the Referer header */ - public function __construct(HttpClient $client, string $userAgent, string $referer = '') { + public function __construct(Client $client, string $userAgent, string $referer = '') { parent::__construct($client); $this->userAgent = $userAgent; diff --git a/tests/TestCase/Geocoder/Provider/GeoIpLookupTest.php b/tests/TestCase/Geocoder/Provider/GeoIpLookupTest.php index 56011f71..0bc0ff0a 100644 --- a/tests/TestCase/Geocoder/Provider/GeoIpLookupTest.php +++ b/tests/TestCase/Geocoder/Provider/GeoIpLookupTest.php @@ -2,10 +2,10 @@ namespace Geo\Test\Geocoder; +use Cake\Http\Client; use Cake\TestSuite\TestCase; use Geo\Geocoder\Provider\GeoIpAddress; use Geo\Geocoder\Provider\GeoIpLookup; -use Http\Adapter\Cake\Client; class GeoIpLookupTest extends TestCase {