Skip to content

Commit d797ec8

Browse files
authored
Merge pull request #371 from norkunas/nohttplug
Remove deprecated `httplug_client` option from providers
2 parents 9f3069c + 3cd1b1c commit d797ec8

28 files changed

+91
-225
lines changed

doc/index.md

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ bazinga_geocoder:
9090
acme:
9191
factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory
9292
options:
93-
httplug_client: '@httplug.client' # When using HTTPlugBundle
93+
http_client: '@any.psr18.client'
9494
region: 'Sweden'
9595
api_key: 'xxyy'
9696
```
@@ -116,7 +116,7 @@ bazinga_geocoder:
116116
factory: Bazinga\GeocoderBundle\ProviderFactory\TomTomFactory
117117
options:
118118
api_key: 'xxyy'
119-
httplug_client: '@httplug.client' # When using HTTPlugBundle
119+
http_client: '@any.psr18.client'
120120
region: 'Sweden'
121121
chain:
122122
factory: Bazinga\GeocoderBundle\ProviderFactory\ChainFactory
@@ -295,17 +295,27 @@ your service argument as: `!tagged bazinga_geocoder.dumper`.
295295

296296
### Custom HTTP Clients
297297

298-
The HTTP geocoder providers integrates with [HTTPlug](http://httplug.io/). It will give you all
299-
the power of the HTTP client. You have to select which one you want to use and how
300-
you want to configure it.
298+
The HTTP geocoder allows to use any [PSR-18](https://www.php-fig.org/psr/psr-18/) compatible client.
299+
In Symfony apps it is recommended to use `symfony/http-client`, but if you want to use Guzzle,
300+
just require it in your dependencies:
301301

302-
Read their [usage page](http://docs.php-http.org/en/latest/httplug/users.html), you
303-
may also be interested in checking out the [HTTPlugBundle](https://github.com/php-http/HttplugBundle).
302+
```bash
303+
composer require guzzlehttp/guzzle http-interop/http-factory-guzzle
304+
```
304305

305-
An example, if you want to use Guzzle6.
306+
And configure your provider to use it:
306307

307-
```bash
308-
composer require php-http/guzzle6-adapter php-http/message
308+
```yaml
309+
services:
310+
guzzle.client:
311+
class: GuzzleHttp\Client
312+
313+
bazinga_geocoder:
314+
providers:
315+
acme:
316+
factory: ...
317+
options:
318+
http_client: '@guzzle.client'
309319
```
310320

311321
Reference Configuration
@@ -372,19 +382,3 @@ Setup the test suite using [Composer](http://getcomposer.org/):
372382
composer update
373383
composer test
374384
```
375-
376-
### Doctrine test
377-
378-
There is also a test that tests the doctrine integration. It runs automatically on
379-
[GitHub Actions](https://github.com/geocoder-php/BazingaGeocoderBundle/actions) but if you want to run it locally you must do the following.
380-
381-
```bash
382-
composer require phpunit/phpunit:^9.5 --no-update
383-
composer update --prefer-source
384-
wget https://phar.phpunit.de/phpunit-9.5.phar
385-
php phpunit-9.5.phar --testsuit doctrine
386-
```
387-
388-
**Important:** this command must be run with `--prefer-source`, otherwise the
389-
`Doctrine\Tests\OrmTestCase` class won't be found.
390-

doc/services.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,35 @@ Here is a list of all provider factories and their options.
1010

1111
| Service | Options |
1212
| ------- | ------- |
13-
| `Bazinga\GeocoderBundle\ProviderFactory\AlgoliaPlaceFactory` | httplug_client, api_key, app_id
14-
| `Bazinga\GeocoderBundle\ProviderFactory\ArcGISOnlineFactory` | httplug_client, source_country
15-
| `Bazinga\GeocoderBundle\ProviderFactory\BingMapsFactory` | httplug_client, api_key
13+
| `Bazinga\GeocoderBundle\ProviderFactory\AlgoliaPlaceFactory` | http_client, api_key, app_id
14+
| `Bazinga\GeocoderBundle\ProviderFactory\ArcGISOnlineFactory` | http_client, source_country
15+
| `Bazinga\GeocoderBundle\ProviderFactory\BingMapsFactory` | http_client, api_key
1616
| `Bazinga\GeocoderBundle\ProviderFactory\ChainFactory` | services
17-
| `Bazinga\GeocoderBundle\ProviderFactory\FreeGeoIpFactory` | httplug_client, base_url
17+
| `Bazinga\GeocoderBundle\ProviderFactory\FreeGeoIpFactory` | http_client, base_url
1818
| `Bazinga\GeocoderBundle\ProviderFactory\GeoIP2Factory` | provider, database_filename, user_id, license_key, webservice_options, locales, provider_service
1919
| `Bazinga\GeocoderBundle\ProviderFactory\GeoipFactory` |
20-
| `Bazinga\GeocoderBundle\ProviderFactory\GeoIPsFactory` | httplug_client, api_key
21-
| `Bazinga\GeocoderBundle\ProviderFactory\GeonamesFactory` | httplug_client, username
22-
| `Bazinga\GeocoderBundle\ProviderFactory\GeoPluginFactory` | httplug_client
23-
| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory` | httplug_client, api_key, region
24-
| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsPlacesFactory` | httplug_client, api_key
25-
| `Bazinga\GeocoderBundle\ProviderFactory\HereFactory` | httplug_client, app_id, app_code, use_cit
26-
| `Bazinga\GeocoderBundle\ProviderFactory\HostIpFactory` | httplug_client
27-
| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoFactory` | httplug_client
28-
| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoDbFactory` | httplug_client, api_key, precision
29-
| `Bazinga\GeocoderBundle\ProviderFactory\IpstackFactory` | httplug_client, api_key
30-
| `Bazinga\GeocoderBundle\ProviderFactory\LocationIQFactory` | httplug_client, api_key
31-
| `Bazinga\GeocoderBundle\ProviderFactory\MapboxFactory` | httplug_client, api_key, country, mode
32-
| `Bazinga\GeocoderBundle\ProviderFactory\MapQuestFactory` | httplug_client, api_key, licensed
33-
| `Bazinga\GeocoderBundle\ProviderFactory\MapzenFactory` | httplug_client, api_key
20+
| `Bazinga\GeocoderBundle\ProviderFactory\GeoIPsFactory` | http_client, api_key
21+
| `Bazinga\GeocoderBundle\ProviderFactory\GeonamesFactory` | http_client, username
22+
| `Bazinga\GeocoderBundle\ProviderFactory\GeoPluginFactory` | http_client
23+
| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory` | http_client, api_key, region
24+
| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsPlacesFactory` | http_client, api_key
25+
| `Bazinga\GeocoderBundle\ProviderFactory\HereFactory` | http_client, app_id, app_code, use_cit
26+
| `Bazinga\GeocoderBundle\ProviderFactory\HostIpFactory` | http_client
27+
| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoFactory` | http_client
28+
| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoDbFactory` | http_client, api_key, precision
29+
| `Bazinga\GeocoderBundle\ProviderFactory\IpstackFactory` | http_client, api_key
30+
| `Bazinga\GeocoderBundle\ProviderFactory\LocationIQFactory` | http_client, api_key
31+
| `Bazinga\GeocoderBundle\ProviderFactory\MapboxFactory` | http_client, api_key, country, mode
32+
| `Bazinga\GeocoderBundle\ProviderFactory\MapQuestFactory` | http_client, api_key, licensed
33+
| `Bazinga\GeocoderBundle\ProviderFactory\MapzenFactory` | http_client, api_key
3434
| `Bazinga\GeocoderBundle\ProviderFactory\MaxMindBinaryFactory` | dat_file, open_flag
35-
| `Bazinga\GeocoderBundle\ProviderFactory\MaxMindFactory` | httplug_client, api_key, endpoint
36-
| `Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory` | httplug_client, root_url
37-
| `Bazinga\GeocoderBundle\ProviderFactory\OpenCageFactory` | httplug_client, api_key
38-
| `Bazinga\GeocoderBundle\ProviderFactory\OpenRouteServiceFactory` | httplug_client, api_key
39-
| `Bazinga\GeocoderBundle\ProviderFactory\PickPointFactory` | httplug_client, api_key
40-
| `Bazinga\GeocoderBundle\ProviderFactory\TomTomFactory` | httplug_client, api_key
41-
| `Bazinga\GeocoderBundle\ProviderFactory\YandexFactory` | httplug_client, toponym
35+
| `Bazinga\GeocoderBundle\ProviderFactory\MaxMindFactory` | http_client, api_key, endpoint
36+
| `Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory` | http_client, root_url
37+
| `Bazinga\GeocoderBundle\ProviderFactory\OpenCageFactory` | http_client, api_key
38+
| `Bazinga\GeocoderBundle\ProviderFactory\OpenRouteServiceFactory` | http_client, api_key
39+
| `Bazinga\GeocoderBundle\ProviderFactory\PickPointFactory` | http_client, api_key
40+
| `Bazinga\GeocoderBundle\ProviderFactory\TomTomFactory` | http_client, api_key
41+
| `Bazinga\GeocoderBundle\ProviderFactory\YandexFactory` | http_client, toponym
4242

4343
### Services
4444

src/ProviderFactory/AlgoliaFactory.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,25 @@ final class AlgoliaFactory extends AbstractFactory
2525
];
2626

2727
/**
28-
* @param array{api_key: ?string, app_id: ?string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config
28+
* @param array{api_key: ?string, app_id: ?string, http_client: ?ClientInterface} $config
2929
*/
3030
protected function getProvider(array $config): Provider
3131
{
32-
$httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
32+
$httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
3333

3434
return new AlgoliaPlaces($httpClient, $config['api_key'], $config['app_id']);
3535
}
3636

3737
protected static function configureOptionResolver(OptionsResolver $resolver)
3838
{
3939
$resolver->setDefaults([
40-
'httplug_client' => null,
4140
'http_client' => null,
4241
'api_key' => null,
4342
'app_id' => null,
4443
]);
4544

46-
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
4745
$resolver->setAllowedTypes('http_client', ['object', 'null']);
4846
$resolver->setAllowedTypes('api_key', ['string', 'null']);
4947
$resolver->setAllowedTypes('app_id', ['string', 'null']);
50-
51-
$resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.');
5248
}
5349
}

src/ProviderFactory/ArcGISOnlineFactory.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@ final class ArcGISOnlineFactory extends AbstractFactory
2525
];
2626

2727
/**
28-
* @param array{source_country: ?string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config
28+
* @param array{source_country: ?string, http_client: ?ClientInterface} $config
2929
*/
3030
protected function getProvider(array $config): Provider
3131
{
32-
$httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
32+
$httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
3333

3434
return new ArcGISOnline($httpClient, $config['source_country']);
3535
}
3636

3737
protected static function configureOptionResolver(OptionsResolver $resolver)
3838
{
3939
$resolver->setDefaults([
40-
'httplug_client' => null,
4140
'http_client' => null,
4241
'source_country' => null,
4342
]);
4443

45-
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
4644
$resolver->setAllowedTypes('http_client', ['object', 'null']);
4745
$resolver->setAllowedTypes('source_country', ['string', 'null']);
48-
49-
$resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.');
5046
}
5147
}

src/ProviderFactory/BingMapsFactory.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@ final class BingMapsFactory extends AbstractFactory
2525
];
2626

2727
/**
28-
* @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config
28+
* @param array{api_key: string, http_client: ?ClientInterface} $config
2929
*/
3030
protected function getProvider(array $config): Provider
3131
{
32-
$httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
32+
$httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
3333

3434
return new BingMaps($httpClient, $config['api_key']);
3535
}
3636

3737
protected static function configureOptionResolver(OptionsResolver $resolver)
3838
{
3939
$resolver->setDefaults([
40-
'httplug_client' => null,
4140
'http_client' => null,
4241
]);
4342

4443
$resolver->setRequired('api_key');
45-
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
4644
$resolver->setAllowedTypes('http_client', ['object', 'null']);
4745
$resolver->setAllowedTypes('api_key', ['string']);
48-
49-
$resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.');
5046
}
5147
}

src/ProviderFactory/FreeGeoIpFactory.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@ final class FreeGeoIpFactory extends AbstractFactory
2525
];
2626

2727
/**
28-
* @param array{base_url: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config
28+
* @param array{base_url: string, http_client: ?ClientInterface} $config
2929
*/
3030
protected function getProvider(array $config): Provider
3131
{
32-
$httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
32+
$httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
3333

3434
return new FreeGeoIp($httpClient, $config['base_url']);
3535
}
3636

3737
protected static function configureOptionResolver(OptionsResolver $resolver)
3838
{
3939
$resolver->setDefaults([
40-
'httplug_client' => null,
4140
'http_client' => null,
4241
'base_url' => 'https://freegeoip.app/json/%s',
4342
]);
4443

45-
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
4644
$resolver->setAllowedTypes('http_client', ['object', 'null']);
4745
$resolver->setAllowedTypes('base_url', ['string']);
48-
49-
$resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.');
5046
}
5147
}

src/ProviderFactory/GeoPluginFactory.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,21 @@ final class GeoPluginFactory extends AbstractFactory
2525
];
2626

2727
/**
28-
* @param array{http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config
28+
* @param array{http_client: ?ClientInterface} $config
2929
*/
3030
protected function getProvider(array $config): Provider
3131
{
32-
$httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
32+
$httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
3333

3434
return new GeoPlugin($httpClient);
3535
}
3636

3737
protected static function configureOptionResolver(OptionsResolver $resolver)
3838
{
3939
$resolver->setDefaults([
40-
'httplug_client' => null,
4140
'http_client' => null,
4241
]);
4342

44-
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
4543
$resolver->setAllowedTypes('http_client', ['object', 'null']);
46-
47-
$resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.');
4844
}
4945
}

src/ProviderFactory/GeonamesFactory.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@ final class GeonamesFactory extends AbstractFactory
2525
];
2626

2727
/**
28-
* @param array{username: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config
28+
* @param array{username: string, http_client: ?ClientInterface} $config
2929
*/
3030
protected function getProvider(array $config): Provider
3131
{
32-
$httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
32+
$httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
3333

3434
return new Geonames($httpClient, $config['username']);
3535
}
3636

3737
protected static function configureOptionResolver(OptionsResolver $resolver)
3838
{
3939
$resolver->setDefaults([
40-
'httplug_client' => null,
4140
'http_client' => null,
4241
]);
4342

4443
$resolver->setRequired('username');
45-
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
4644
$resolver->setAllowedTypes('http_client', ['object', 'null']);
4745
$resolver->setAllowedTypes('username', ['string']);
48-
49-
$resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.');
5046
}
5147
}

src/ProviderFactory/GoogleMapsFactory.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,25 @@ final class GoogleMapsFactory extends AbstractFactory
2525
];
2626

2727
/**
28-
* @param array{api_key: ?string, region: ?string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config
28+
* @param array{api_key: ?string, region: ?string, http_client: ?ClientInterface} $config
2929
*/
3030
protected function getProvider(array $config): Provider
3131
{
32-
$httpClient = $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
32+
$httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
3333

3434
return new GoogleMaps($httpClient, $config['region'], $config['api_key']);
3535
}
3636

3737
protected static function configureOptionResolver(OptionsResolver $resolver)
3838
{
3939
$resolver->setDefaults([
40-
'httplug_client' => null,
4140
'http_client' => null,
4241
'region' => null,
4342
'api_key' => null,
4443
]);
4544

46-
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
4745
$resolver->setAllowedTypes('http_client', ['object', 'null']);
4846
$resolver->setAllowedTypes('region', ['string', 'null']);
4947
$resolver->setAllowedTypes('api_key', ['string', 'null']);
50-
51-
$resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "%name%" is deprecated, use "http_client" instead.');
5248
}
5349
}

src/ProviderFactory/GoogleMapsPlacesFactory.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,23 @@ final class GoogleMapsPlacesFactory extends AbstractFactory
2525
];
2626

2727
/**
28-
* @param array{api_key: string, http_client: ?ClientInterface, httplug_client: ?ClientInterface} $config
28+
* @param array{api_key: string, http_client: ?ClientInterface} $config
2929
*/
3030
protected function getProvider(array $config): Provider
3131
{
32-
$httpClient = $config['http_client'] ?? $config['httplug_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
32+
$httpClient = $config['http_client'] ?? $this->httpClient ?? Psr18ClientDiscovery::find();
3333

3434
return new GoogleMapsPlaces($httpClient, $config['api_key']);
3535
}
3636

3737
protected static function configureOptionResolver(OptionsResolver $resolver)
3838
{
3939
$resolver->setDefaults([
40-
'httplug_client' => null,
4140
'http_client' => null,
4241
]);
4342

44-
$resolver->setAllowedTypes('httplug_client', ['object', 'null']);
4543
$resolver->setAllowedTypes('http_client', ['object', 'null']);
4644
$resolver->setRequired(['api_key']);
4745
$resolver->setAllowedTypes('api_key', ['string']);
48-
49-
$resolver->setDeprecated('httplug_client', 'willdurand/geocoder-bundle', '5.19', 'The option "httplug_client" is deprecated, use "http_client" instead.');
5046
}
5147
}

0 commit comments

Comments
 (0)