Skip to content

Commit a176180

Browse files
authored
Merge pull request #49 from geocoder-php/feature/update-for-laravel-5-3
WIP: Bring Up To Par With Geocoder 3.3.0
2 parents e801a11 + 090bc89 commit a176180

16 files changed

+714
-436
lines changed

CHANGELOG.md

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,64 @@
1-
CHANGELOG
2-
=========
1+
# Geocoder for Laravel Changelog
2+
All notable changes to this project will be documented in this file.
3+
This project adheres to [Semantic Versioning](http://semver.org/).
34

4-
0.5.0 (2015-03-11)
5-
------------------
5+
## [1.0.0] - 3 Oct 2016
6+
### Added
7+
- ability to dump results #16.
8+
- ability to use multiple providers in addition to the chain provider #47.
9+
- more integration tests.
10+
- special aggregator that allows chaining of `geocode()` and other methods.
611

7-
* [BC] the package is now compatible for Laravel 5
8-
* improved the doc
9-
* add code of conduct
12+
### Changed
13+
- README documentation.
14+
- to use Geocoder 3.3.x.
15+
- namespace to `Geocoder\Laravel\...`.
16+
- service provider to auto-load the facade.
17+
- config file format.
18+
- geocoding commands necessary to obtain results (must use `->all()`, `->get()`,
19+
or `->dump()`) after the respective command.
20+
- the service provider architecture.
1021

11-
0.4.1 (2014-06-23)
12-
------------------
22+
### Fixed
23+
- MaxMindBinary Provider being instantiated with an Adapter #24.
24+
- GeoIP2 Provider being instantiated with a generic Adapter.
1325

14-
* fix the way to implode provider's arguments + unit tests
26+
### Removed
27+
- TravisCI and Coveralls CI in favor of PHPCI.
1528

16-
0.4.0 (2014-04-13)
17-
------------------
29+
## [0.6.0]
30+
- TBD
1831

19-
* use Geocoder 2.4.*
32+
## [0.5.0] - 11 Mar 2015
33+
### Added
34+
- code of conduct message.
35+
- Laravel 5 compatibility [BC].
2036

37+
### Updated
38+
- documentation.
2139

22-
0.3.0 (2014-04-13)
23-
------------------
40+
## [0.4.1] - 23 Jun 2014
41+
### Fixed
42+
- the way to implode provider's arguments + unit tests.
2443

25-
* support provider's arugments (BC break)
44+
## [0.4.0] - 13 Apr 2014
45+
### Updated
46+
- to use Geocoder 2.4.x.
2647

48+
## [0.3.0] - 13 Apr 2014
49+
### Added
50+
- support for Provider arguments (backwards-compatibility break).
2751

28-
0.2.0 (2013-11-16)
29-
------------------
52+
## [0.2.0] - 16 Nov 2013
53+
### Added
54+
- config file.
3055

31-
* use Geocoder 2.3.x
32-
* use config file
33-
* use singleton instead of share
34-
* improve tests
56+
### Updated
57+
- to use Geocoder 2.3.x.
58+
- to use singleton instead of share.
59+
- tests.
3560

36-
37-
0.1.0 (2013-09-16)
38-
------------------
39-
40-
* add badges
41-
* initial import
61+
## [0.1.0] - 16 Sep 2013
62+
### Added
63+
- badges.
64+
- initial package.

README.md

Lines changed: 98 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,125 @@
1-
Geocoder for Lavarel 5
2-
======================
3-
4-
If you still use **Laravel 4**, please check out the `0.4.x` branch [here](https://github.com/geocoder-php/GeocoderLaravel/tree/0.4.x).
5-
6-
This package allows you to use [**Geocoder**](http://geocoder-php.org/Geocoder/)
7-
in [**Laravel 5**](http://laravel.com/).
8-
91
[![Latest StableVersion](https://poser.pugx.org/toin0u/geocoder-laravel/v/stable.png)](https://packagist.org/packages/toin0u/geocoder-laravel)
102
[![Total Downloads](https://poser.pugx.org/toin0u/geocoder-laravel/downloads.png)](https://packagist.org/packages/toin0u/geocoder-laravel)
11-
[![Build Status](https://secure.travis-ci.org/geocoder-php/GeocoderLaravel.png)](http://travis-ci.org/geocoder-php/GeocoderLaravel)
12-
[![Coverage Status](https://coveralls.io/repos/geocoder-php/GeocoderLaravel/badge.png)](https://coveralls.io/r/geocoder-php/GeocoderLaravel)
13-
3+
[![Build Status](https://ci.genealabs.com/build-status/image/1)](https://ci.genealabs.com/build-status/view/1)
4+
[Code Coverage](https://ci.genealabs.com/coverage/1)
145

15-
Installation
16-
------------
6+
# Geocoder for Lavarel
177

18-
It can be found on [Packagist](https://packagist.org/packages/toin0u/geocoder-laravel).
19-
The recommended way is through [composer](http://getcomposer.org).
8+
> If you still use **Laravel 4**, please check out the `0.4.x` branch
9+
[here](https://github.com/geocoder-php/GeocoderLaravel/tree/0.4.x).
2010

21-
Edit `composer.json` and add:
11+
** Version 1.0.0 is a backwards-compatibility-breaking update. Please review
12+
this documentation, especially the _Usage_ section before installing. **
2213

23-
```json
24-
{
25-
"require": {
26-
"toin0u/geocoder-laravel": "@stable"
27-
}
28-
}
29-
```
30-
31-
**Protip:** you should browse the
32-
[`toin0u/geocoder-laravel`](https://packagist.org/packages/toin0u/geocoder-laravel)
33-
page to choose a stable version to use, avoid the `@stable` meta constraint.
34-
35-
And install dependencies:
36-
```bash
37-
$ composer update
14+
This package allows you to use [**Geocoder**](http://geocoder-php.org/Geocoder/)
15+
in [**Laravel 5**](http://laravel.com/).
16+
17+
## Installation
18+
1. Install the package via composer:
19+
```sh
20+
composer require toin0u/geocoder-laravel
21+
```
22+
23+
2. Find the `providers` array key in `config/app.php` and register the **Geocoder
24+
Service Provider**:
25+
```php
26+
// 'providers' => [
27+
Geocoder\Laravel\Providers\GeocoderService::class,
28+
// ];
29+
```
30+
31+
## Configuration
32+
Pay special attention to the language and region values if you are using them.
33+
For example, the GoogleMaps provider uses TLDs for region values, and the
34+
following for language values: https://developers.google.com/maps/faq#languagesupport.
35+
36+
Further, a special note on the GoogleMaps provider: if you are using an API key,
37+
you must also use set HTTPS to true. (Best is to leave it true always, unless
38+
there is a special requirement not to.)
39+
40+
See the [Geocoder documentation](http://geocoder-php.org/Geocoder/) for a list
41+
of available adapters and providers.
42+
43+
### Default Settings
44+
By default, the configuration specifies a Chain Provider as the first provider,
45+
containing GoogleMaps and FreeGeoIp providers. The first to return a result
46+
will be returned. After the Chain Provider, we have added the BingMaps provider
47+
for use in specific situations (providers contained in the Chain provider will
48+
be run by default, providers not in the Chain provider need to be called
49+
explicitly). The second GoogleMaps Provider outside of the Chain Provider is
50+
there just to illustrate this point (and is used by the PHPUnit tests).
51+
```php
52+
return [
53+
'providers' => [
54+
Chain::class => [
55+
GoogleMaps::class => [
56+
'en',
57+
'us',
58+
true,
59+
env('GOOGLE_MAPS_API_KEY'),
60+
],
61+
FreeGeoIp::class => [],
62+
],
63+
BingMaps::class => [
64+
'en-US',
65+
env('BING_MAPS_API_KEY'),
66+
],
67+
GoogleMaps::class => [
68+
'en',
69+
'us',
70+
true,
71+
env('GOOGLE_MAPS_API_KEY'),
72+
],
73+
],
74+
'adapter' => CurlHttpAdapter::class,
75+
];
3876
```
3977

40-
If you do not have [**Composer**](https://getcomposer.org) installed, run these two commands:
41-
42-
```bash
43-
$ curl -sS https://getcomposer.org/installer | php
44-
$ php composer.phar install
78+
### Customization
79+
If you would like to make changes to the default configuration, publish and
80+
edit the configuration file:
81+
```sh
82+
php artisan vendor:publish --provider="Geocoder\Laravel\GeocoderServiceProvider" --tags="config"
4583
```
4684

85+
## Usage
86+
The service provider initializes the `geocoder` service, accessible via the
87+
facade `Geocoder::...` or the application helper `app('geocoder')->...`.
4788

48-
Usage
49-
-----
50-
51-
Find the `providers` array key in `config/app.php` and register the **Geocoder Service Provider**.
52-
89+
### Geocoding Addresses
90+
#### Get Collection of Addresses
5391
```php
54-
'providers' => array(
55-
// ...
56-
57-
Toin0u\Geocoder\GeocoderServiceProvider::class,
58-
)
92+
app('geocoder')->geocode('Los Angeles, CA')->get();
5993
```
6094

61-
Find the `aliases` array key in `config/app.php` and register the **Geocoder Facade**.
62-
95+
#### Get Array of Addresses
6396
```php
64-
'aliases' => array(
65-
// ...
66-
67-
'Geocoder' => Toin0u\Geocoder\Facade\Geocoder::class,
68-
)
97+
app('geocoder')->geocode('Los Angeles, CA')->all();
6998
```
7099

71-
Configuration
72-
-------------
73-
74-
Publish and edit the configuration file
75-
76-
```bash
77-
$ php artisan vendor:publish --provider="toin0u/geocoder-laravel"
78-
```
79-
80-
The service provider creates the following services:
81-
82-
* `geocoder`: the Geocoder instance.
83-
* `geocoder.chain`: the chain provider used by Geocoder.
84-
* `geocoder.adapter`: the HTTP adapter used to get data from remotes APIs.
85-
86-
By default, the `geocoder.chain` service contains `GoogleMapsProvider` and `FreeGeoIpProvider`.
87-
The `geocoder.adapter` service uses the cURL adapter. Override these services to use the
88-
adapter/providers you want by editing `config/geocoder.php`:
89-
100+
#### Reverse-Geocoding
90101
```php
91-
return [
92-
'providers' => [
93-
'\Geocoder\Provider\GoogleMapsProvider' => ['en_EN', 'my-region', $ssl = false, 'MY_API_KEY'],
94-
'\Geocoder\Provider\GoogleMapsBusinessProvider' => ['my-locale', 'my-region', $ssl = true, 'MY_API_KEY'],
95-
],
96-
'adapter' => '\Geocoder\HttpAdapter\CurlHttpAdapter'
97-
];
102+
app('geocoder')->reverse(43.882587,-103.454067)->get();
98103
```
99104

100-
NB: As you can see the array value of the provider is the constructor arguments.
101-
102-
See [the Geocoder documentation](http://geocoder-php.org/Geocoder/) for a list of available adapters and providers.
103-
104-
105-
Example with Facade
106-
-------------------
107-
105+
#### Dumping Results
108106
```php
109-
<?php
110-
111-
// ...
112-
try {
113-
$geocode = Geocoder::geocode('10 rue Gambetta, Paris, France');
114-
// The GoogleMapsProvider will return a result
115-
var_dump($geocode);
116-
} catch (\Exception $e) {
117-
// No exception will be thrown here
118-
echo $e->getMessage();
119-
}
107+
app('geocoder')->geocode('Los Angeles, CA')->dump('kml');
120108
```
121109

110+
## Changelog
111+
https://github.com/geocoder-php/GeocoderLaravel/blob/master/CHANGELOG.md
122112

123-
Changelog
124-
---------
125-
126-
[See the CHANGELOG file](https://github.com/geocoder-php/GeocoderLaravel/blob/master/CHANGELOG.md)
127-
128-
129-
Support
130-
-------
131-
132-
[Please open an issue on GitHub](https://github.com/geocoder-php/GeocoderLaravel/issues)
133-
134-
135-
Contributor Code of Conduct
136-
---------------------------
137-
138-
Please note that this project is released with a Contributor Code of Conduct.
139-
By participating in this project you agree to abide by its terms.
140-
113+
## Support
114+
If you are experiencing difficulties, please please open an issue on GitHub:
115+
https://github.com/geocoder-php/GeocoderLaravel/issues.
141116

142-
License
143-
-------
117+
## Contributor Code of Conduct
118+
Please note that this project is released with a
119+
[Contributor Code of Conduct](https://github.com/geocoder-php/Geocoder#contributor-code-of-conduct).
120+
By participating in this project you agree to abide by its terms.
144121

122+
## License
145123
GeocoderLaravel is released under the MIT License. See the bundled
146-
[LICENSE](https://github.com/geocoder-php/GeocoderLaravel/blob/master/LICENSE)
147-
file for details.
124+
[LICENSE](https://github.com/geocoder-php/GeocoderLaravel/blob/master/LICENSE)
125+
file for details.

0 commit comments

Comments
 (0)