Skip to content

Commit b1602e3

Browse files
authored
Merge branch 'master' into feature/drop-support-php
2 parents e3b137d + 5852b70 commit b1602e3

39 files changed

+208
-335
lines changed

.editorconfig

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,18 @@ indent_style = space
88
insert_final_newline = true
99
trim_trailing_whitespace = true
1010

11-
[*.{yml,yaml}]
11+
[.github/**/*.{yml,yaml}]
1212
indent_size = 2
13+
14+
[*.{yml,yaml}]
15+
trim_trailing_whitespace = false
16+
17+
[**.md]
18+
indent_size = unset
19+
indent_style = unset
20+
21+
[*.json]
22+
insert_final_newline = false
23+
24+
[*.{neon,neon.dist}]
25+
indent_style = tab

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@
7272
"symfony/var-exporter": "^6.4 || ^7.0",
7373
"symfony/yaml": "^6.4 || ^7.0"
7474
},
75-
"conflict": {
76-
"geocoder-php/nominatim-provider": "<5.0"
77-
},
7875
"autoload": {
7976
"psr-4": {
8077
"Bazinga\\GeocoderBundle\\": "src/"
@@ -86,7 +83,7 @@
8683
}
8784
},
8885
"scripts": {
89-
"test": "vendor/bin/simple-phpunit --testsuite main"
86+
"test": "SYMFONY_DEPRECATIONS_HELPER=ignoreFile='./tests/baseline-ignore' vendor/bin/simple-phpunit --testsuite main"
9087
},
9188
"config": {
9289
"allow-plugins": {

config/profiling.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
6+
7+
use Bazinga\GeocoderBundle\DataCollector\GeocoderDataCollector;
8+
9+
return static function (ContainerConfigurator $container) {
10+
$services = $container->services();
11+
12+
$services->set(GeocoderDataCollector::class)
13+
->tag('data_collector', ['template' => '@BazingaGeocoder/Collector/geocoder.html.twig', 'id' => 'geocoder']);
14+
};

config/profiling.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

config/services.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
6+
7+
use Bazinga\GeocoderBundle\Command\GeocodeCommand;
8+
use Bazinga\GeocoderBundle\Plugin\FakeIpPlugin;
9+
use Bazinga\GeocoderBundle\Validator\Constraint\AddressValidator;
10+
use Geocoder\Dumper\Dumper;
11+
use Geocoder\Dumper\GeoArray;
12+
use Geocoder\Dumper\GeoJson;
13+
use Geocoder\Dumper\Gpx;
14+
use Geocoder\Dumper\Kml;
15+
use Geocoder\Dumper\Wkb;
16+
use Geocoder\Dumper\Wkt;
17+
use Geocoder\ProviderAggregator;
18+
19+
return static function (ContainerConfigurator $container) {
20+
$services = $container->services();
21+
$services->instanceof(Dumper::class)
22+
->public();
23+
24+
$services
25+
->set(GeoArray::class)
26+
->set(GeoJson::class)
27+
->set(Gpx::class)
28+
->set(Kml::class)
29+
->set(Wkb::class)
30+
->set(Wkt::class)
31+
32+
->load('Bazinga\\GeocoderBundle\\ProviderFactory\\', __DIR__.'/../src/ProviderFactory')
33+
->autowire()
34+
->autoconfigure()
35+
36+
->set(ProviderAggregator::class)
37+
38+
->set(FakeIpPlugin::class)
39+
->args([null, null, false])
40+
41+
->set(GeocodeCommand::class)
42+
->args([
43+
service(ProviderAggregator::class),
44+
])
45+
->tag('console.command')
46+
47+
->set(AddressValidator::class)
48+
->args([
49+
service(ProviderAggregator::class),
50+
])
51+
->tag('validator.constraint_validator')
52+
;
53+
};

config/services.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

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 & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +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\GeonamesFactory` | httplug_client, username
21-
| `Bazinga\GeocoderBundle\ProviderFactory\GeoPluginFactory` | httplug_client
22-
| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory` | httplug_client, api_key, region
23-
| `Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsPlacesFactory` | httplug_client, api_key
24-
| `Bazinga\GeocoderBundle\ProviderFactory\HereFactory` | httplug_client, app_id, app_code, use_cit
25-
| `Bazinga\GeocoderBundle\ProviderFactory\HostIpFactory` | httplug_client
26-
| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoFactory` | httplug_client
27-
| `Bazinga\GeocoderBundle\ProviderFactory\IpInfoDbFactory` | httplug_client, api_key, precision
28-
| `Bazinga\GeocoderBundle\ProviderFactory\IpstackFactory` | httplug_client, api_key
29-
| `Bazinga\GeocoderBundle\ProviderFactory\LocationIQFactory` | httplug_client, api_key
30-
| `Bazinga\GeocoderBundle\ProviderFactory\MapboxFactory` | httplug_client, api_key, country, mode
31-
| `Bazinga\GeocoderBundle\ProviderFactory\MapQuestFactory` | httplug_client, api_key, licensed
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
3234
| `Bazinga\GeocoderBundle\ProviderFactory\MaxMindBinaryFactory` | dat_file, open_flag
33-
| `Bazinga\GeocoderBundle\ProviderFactory\MaxMindFactory` | httplug_client, api_key, endpoint
34-
| `Bazinga\GeocoderBundle\ProviderFactory\NominatimFactory` | httplug_client, root_url
35-
| `Bazinga\GeocoderBundle\ProviderFactory\OpenCageFactory` | httplug_client, api_key
36-
| `Bazinga\GeocoderBundle\ProviderFactory\OpenRouteServiceFactory` | httplug_client, api_key
37-
| `Bazinga\GeocoderBundle\ProviderFactory\PickPointFactory` | httplug_client, api_key
38-
| `Bazinga\GeocoderBundle\ProviderFactory\TomTomFactory` | httplug_client, api_key
39-
| `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
4042

4143
### Services
4244

src/Command/GeocodeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/**
2525
* @author Markus Bachmann <[email protected]>
2626
*/
27-
#[AsCommand(name: 'geocoder:geocode', description: 'Geocode an address or a ip address')]
27+
#[AsCommand(name: 'geocoder:geocode', description: 'Geocode an address or an IP address')]
2828
class GeocodeCommand extends Command
2929
{
3030
private ProviderAggregator $geocoder;

src/DependencyInjection/BazingaGeocoderExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
use Symfony\Component\DependencyInjection\ContainerBuilder;
3232
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
3333
use Symfony\Component\DependencyInjection\Extension\Extension;
34-
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
34+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
3535
use Symfony\Component\DependencyInjection\Reference;
3636

3737
/**
@@ -50,11 +50,11 @@ public function load(array $configs, ContainerBuilder $container)
5050
$configuration = $this->getConfiguration($configs, $container);
5151
$config = $processor->processConfiguration($configuration, $configs);
5252

53-
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../../config'));
54-
$loader->load('services.yml');
53+
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../config'));
54+
$loader->load('services.php');
5555

5656
if (true === $config['profiling']['enabled']) {
57-
$loader->load('profiling.yml');
57+
$loader->load('profiling.php');
5858
}
5959

6060
if ($config['fake_ip']['enabled']) {

0 commit comments

Comments
 (0)