10
10
> If you still use ** Laravel 4** , please check out the ` 0.4.x ` branch
11
11
[ here] ( https://github.com/geocoder-php/GeocoderLaravel/tree/0.4.x ) .
12
12
13
- ** Version 2 .0.0 is a backwards-compatibility-breaking update. Please review
13
+ ** Version 4 .0.0 is a backwards-compatibility-breaking update. Please review
14
14
this documentation, especially the _ Usage_ section before installing.**
15
15
16
16
This package allows you to use [ ** Geocoder** ] ( http://geocoder-php.org/Geocoder/ )
@@ -26,18 +26,18 @@ This package allows you to use [**Geocoder**](http://geocoder-php.org/Geocoder/)
26
26
composer require toin0u/geocoder-laravel
27
27
```
28
28
29
- 2 . Find the ` providers ` array key in ` config/app.php ` and register the ** Geocoder Service Provider** :
29
+ 2 . ** If you are running Laravel 5.5, skip this step. ** Find the ` providers ` array key in ` config/app.php ` and register the ** Geocoder Service Provider** :
30
30
``` php
31
31
// 'providers' => [
32
32
Geocoder\Laravel\Providers\GeocoderService::class,
33
33
// ];
34
34
```
35
35
36
36
## Upgrading
37
- ### 1.x to 2 .x
37
+ ### 1.x to 4 .x
38
38
Update your composer.json file:
39
39
``` json
40
- "toin0u/geocoder-laravel" : " ^2 .0" ,
40
+ "toin0u/geocoder-laravel" : " ^4 .0" ,
41
41
```
42
42
43
43
The one change to keep in mind here is that the results returned from
@@ -108,19 +108,22 @@ Further, a special note on the GoogleMaps provider: if you are using an API key,
108
108
See the [Geocoder documentation](http://geocoder-php.org/Geocoder/) for a list
109
109
of available adapters and providers.
110
110
111
- ### Default Settings
112
- If you are upgrading and do not update your config file with the `cache-duraction`
113
- variable, cache will by default be disabled (it will have a `0` cache duration).
114
- The default cache duration provided by the config file is `999999999` minutes,
115
- essentially forever.
116
-
117
- By default, the configuration specifies a Chain Provider as the first provider,
118
- containing GoogleMaps and FreeGeoIp providers. The first to return a result
119
- will be returned. After the Chain Provider, we have added the BingMaps provider
120
- for use in specific situations (providers contained in the Chain provider will
121
- be run by default, providers not in the Chain provider need to be called
122
- explicitly). The second GoogleMaps Provider outside of the Chain Provider is
123
- there just to illustrate this point (and is used by the PHPUnit tests).
111
+ ### Configuration
112
+ #### Providers
113
+ If you are upgrading and have previously published the geocoder config file, you
114
+ need to add the `cache-duration` variable, otherwise cache will be disabled
115
+ (it will default to a `0` cache duration). The default cache duration provided
116
+ by the config file is `999999999` minutes, essentially forever.
117
+
118
+ By default, the configuration specifies a Chain provider, containing the
119
+ GoogleMaps provider for addresses as well as reverse lookups with lat/long,
120
+ and the GeoIP provider for IP addresses. The first to return a result
121
+ will be returned, and subsequent providers will not be executed. The default
122
+ config file is kept lean with only those two providers.
123
+
124
+ However, you are free to add or remove providers as needed, both inside the
125
+ Chain provider, as well as along-side it. The following is an example config
126
+ with additional providers we use for testing:
124
127
```php
125
128
use Http\Client\Curl\Client;
126
129
use Geocoder\Provider\BingMaps\BingMaps;
@@ -129,7 +132,7 @@ use Geocoder\Provider\FreeGeoIp\FreeGeoIp;
129
132
use Geocoder\Provider\GoogleMaps\GoogleMaps;
130
133
131
134
return [
132
- 'cache-duraction ' => 999999999,
135
+ 'cache-duration ' => 999999999,
133
136
'providers' => [
134
137
Chain::class => [
135
138
GoogleMaps::class => [
@@ -151,6 +154,13 @@ return [
151
154
];
152
155
```
153
156
157
+ #### Adapters
158
+ By default we provide a CURL adapter to get you running out of the box.
159
+ However, if you have already installed Guzzle or any other PSR-7-compatible
160
+ HTTP adapter, you are encouraged to replace the CURL adapter with it. Please
161
+ see the [ Geocoder Documentation] ( https://github.com/geocoder-php/Geocoder ) for
162
+ specific implementation details.
163
+
154
164
### Customization
155
165
If you would like to make changes to the default configuration, publish and
156
166
edit the configuration file:
@@ -168,6 +178,11 @@ The service provider initializes the `geocoder` service, accessible via the
168
178
app('geocoder')->geocode('Los Angeles, CA')->get();
169
179
```
170
180
181
+ #### Get IP Address Information
182
+ ``` php
183
+ app('geocoder')->geocode('8.8.8.8')->get();
184
+ ```
185
+
171
186
#### Reverse-Geocoding
172
187
``` php
173
188
app('geocoder')->reverse(43.882587,-103.454067)->get();
@@ -193,4 +208,4 @@ Please note that this project is released with a
193
208
## License
194
209
GeocoderLaravel is released under the MIT License. See the bundled
195
210
[ LICENSE] ( https://github.com/geocoder-php/GeocoderLaravel/blob/master/LICENSE )
196
- file for details.
211
+ file for details.
0 commit comments