-
Notifications
You must be signed in to change notification settings - Fork 106
WIP: Bring Up To Par With Geocoder 3.3.0 #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
21768be
Updating for Laravel 5.3
mikebronner 3f1d8b6
Updated config
mikebronner 34b6148
Merged branch master into feature/update-for-laravel-5-3
mikebronner 4b89847
Merged branch master into master
mikebronner 7f857c7
Update publish command in readme
mikebronner 4cab9bc
Merged branch master into feature/update-for-laravel-5-3
mikebronner a6d9e34
Re-arrange tests, make sure IP addresses are geocoded.
mikebronner 245ff56
Implement fix for specialized providers
mikebronner 4926302
Implement multiple providers
mikebronner 1b25952
Refactor and clean up the service provider
mikebronner f115148
Create chainable provider with dump functionality
mikebronner 379682d
Update tests
mikebronner 31d1819
Update documentation, changelog, change namespace
mikebronner 7050192
Fix namespaces in README
mikebronner 964d30c
Fix examples in readme
mikebronner 4a4e152
Remove erroneous use statement from readme
mikebronner 8f07737
Implement stand-along package tests
mikebronner c4b423c
Update travis config
mikebronner cfd14a7
Update composer.json
mikebronner 49e32f9
WIP - configuring PHPCI
mikebronner 00bedff
Fix phpci config filename
mikebronner e01edb8
WIP - getting PHPCI to respect configuration
mikebronner c63423e
WIP - remove phpci config file, update readme with build status icon …
mikebronner 6c4ac31
Improve quality of some of the integration tests
mikebronner 1f35c25
Update phpunit config and add link to code coverage
mikebronner b46213e
Fix autoload declaration
mikebronner 9ce156f
Add travis config file back in
mikebronner 090bc89
Place namespace declaration below file comment
mikebronner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,64 @@ | ||
CHANGELOG | ||
========= | ||
# Geocoder for Laravel Changelog | ||
All notable changes to this project will be documented in this file. | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
|
||
0.5.0 (2015-03-11) | ||
------------------ | ||
## [1.0.0] - 3 Oct 2016 | ||
### Added | ||
- ability to dump results #16. | ||
- ability to use multiple providers in addition to the chain provider #47. | ||
- more integration tests. | ||
- special aggregator that allows chaining of `geocode()` and other methods. | ||
|
||
* [BC] the package is now compatible for Laravel 5 | ||
* improved the doc | ||
* add code of conduct | ||
### Changed | ||
- README documentation. | ||
- to use Geocoder 3.3.x. | ||
- namespace to `Geocoder\Laravel\...`. | ||
- service provider to auto-load the facade. | ||
- config file format. | ||
- geocoding commands necessary to obtain results (must use `->all()`, `->get()`, | ||
or `->dump()`) after the respective command. | ||
- the service provider architecture. | ||
|
||
0.4.1 (2014-06-23) | ||
------------------ | ||
### Fixed | ||
- MaxMindBinary Provider being instantiated with an Adapter #24. | ||
- GeoIP2 Provider being instantiated with a generic Adapter. | ||
|
||
* fix the way to implode provider's arguments + unit tests | ||
### Removed | ||
- TravisCI and Coveralls CI in favor of PHPCI. | ||
|
||
0.4.0 (2014-04-13) | ||
------------------ | ||
## [0.6.0] | ||
- TBD | ||
|
||
* use Geocoder 2.4.* | ||
## [0.5.0] - 11 Mar 2015 | ||
### Added | ||
- code of conduct message. | ||
- Laravel 5 compatibility [BC]. | ||
|
||
### Updated | ||
- documentation. | ||
|
||
0.3.0 (2014-04-13) | ||
------------------ | ||
## [0.4.1] - 23 Jun 2014 | ||
### Fixed | ||
- the way to implode provider's arguments + unit tests. | ||
|
||
* support provider's arugments (BC break) | ||
## [0.4.0] - 13 Apr 2014 | ||
### Updated | ||
- to use Geocoder 2.4.x. | ||
|
||
## [0.3.0] - 13 Apr 2014 | ||
### Added | ||
- support for Provider arguments (backwards-compatibility break). | ||
|
||
0.2.0 (2013-11-16) | ||
------------------ | ||
## [0.2.0] - 16 Nov 2013 | ||
### Added | ||
- config file. | ||
|
||
* use Geocoder 2.3.x | ||
* use config file | ||
* use singleton instead of share | ||
* improve tests | ||
### Updated | ||
- to use Geocoder 2.3.x. | ||
- to use singleton instead of share. | ||
- tests. | ||
|
||
|
||
0.1.0 (2013-09-16) | ||
------------------ | ||
|
||
* add badges | ||
* initial import | ||
## [0.1.0] - 16 Sep 2013 | ||
### Added | ||
- badges. | ||
- initial package. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,147 +1,125 @@ | ||
Geocoder for Lavarel 5 | ||
====================== | ||
|
||
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). | ||
|
||
This package allows you to use [**Geocoder**](http://geocoder-php.org/Geocoder/) | ||
in [**Laravel 5**](http://laravel.com/). | ||
|
||
[](https://packagist.org/packages/toin0u/geocoder-laravel) | ||
[](https://packagist.org/packages/toin0u/geocoder-laravel) | ||
[](http://travis-ci.org/geocoder-php/GeocoderLaravel) | ||
[](https://coveralls.io/r/geocoder-php/GeocoderLaravel) | ||
|
||
[](https://ci.genealabs.com/build-status/view/1) | ||
[Code Coverage](https://ci.genealabs.com/coverage/1) | ||
|
||
Installation | ||
------------ | ||
# Geocoder for Lavarel | ||
|
||
It can be found on [Packagist](https://packagist.org/packages/toin0u/geocoder-laravel). | ||
The recommended way is through [composer](http://getcomposer.org). | ||
> 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). | ||
|
||
Edit `composer.json` and add: | ||
** Version 1.0.0 is a backwards-compatibility-breaking update. Please review | ||
this documentation, especially the _Usage_ section before installing. ** | ||
|
||
```json | ||
{ | ||
"require": { | ||
"toin0u/geocoder-laravel": "@stable" | ||
} | ||
} | ||
``` | ||
|
||
**Protip:** you should browse the | ||
[`toin0u/geocoder-laravel`](https://packagist.org/packages/toin0u/geocoder-laravel) | ||
page to choose a stable version to use, avoid the `@stable` meta constraint. | ||
|
||
And install dependencies: | ||
```bash | ||
$ composer update | ||
This package allows you to use [**Geocoder**](http://geocoder-php.org/Geocoder/) | ||
in [**Laravel 5**](http://laravel.com/). | ||
|
||
## Installation | ||
1. Install the package via composer: | ||
```sh | ||
composer require toin0u/geocoder-laravel | ||
``` | ||
|
||
2. Find the `providers` array key in `config/app.php` and register the **Geocoder | ||
Service Provider**: | ||
```php | ||
// 'providers' => [ | ||
Geocoder\Laravel\Providers\GeocoderService::class, | ||
// ]; | ||
``` | ||
|
||
## Configuration | ||
Pay special attention to the language and region values if you are using them. | ||
For example, the GoogleMaps provider uses TLDs for region values, and the | ||
following for language values: https://developers.google.com/maps/faq#languagesupport. | ||
|
||
Further, a special note on the GoogleMaps provider: if you are using an API key, | ||
you must also use set HTTPS to true. (Best is to leave it true always, unless | ||
there is a special requirement not to.) | ||
|
||
See the [Geocoder documentation](http://geocoder-php.org/Geocoder/) for a list | ||
of available adapters and providers. | ||
|
||
### Default Settings | ||
By default, the configuration specifies a Chain Provider as the first provider, | ||
containing GoogleMaps and FreeGeoIp providers. The first to return a result | ||
will be returned. After the Chain Provider, we have added the BingMaps provider | ||
for use in specific situations (providers contained in the Chain provider will | ||
be run by default, providers not in the Chain provider need to be called | ||
explicitly). The second GoogleMaps Provider outside of the Chain Provider is | ||
there just to illustrate this point (and is used by the PHPUnit tests). | ||
```php | ||
return [ | ||
'providers' => [ | ||
Chain::class => [ | ||
GoogleMaps::class => [ | ||
'en', | ||
'us', | ||
true, | ||
env('GOOGLE_MAPS_API_KEY'), | ||
], | ||
FreeGeoIp::class => [], | ||
], | ||
BingMaps::class => [ | ||
'en-US', | ||
env('BING_MAPS_API_KEY'), | ||
], | ||
GoogleMaps::class => [ | ||
'en', | ||
'us', | ||
true, | ||
env('GOOGLE_MAPS_API_KEY'), | ||
], | ||
], | ||
'adapter' => CurlHttpAdapter::class, | ||
]; | ||
``` | ||
|
||
If you do not have [**Composer**](https://getcomposer.org) installed, run these two commands: | ||
|
||
```bash | ||
$ curl -sS https://getcomposer.org/installer | php | ||
$ php composer.phar install | ||
### Customization | ||
If you would like to make changes to the default configuration, publish and | ||
edit the configuration file: | ||
```sh | ||
php artisan vendor:publish --provider="Geocoder\Laravel\GeocoderServiceProvider" --tags="config" | ||
``` | ||
|
||
## Usage | ||
The service provider initializes the `geocoder` service, accessible via the | ||
facade `Geocoder::...` or the application helper `app('geocoder')->...`. | ||
|
||
Usage | ||
----- | ||
|
||
Find the `providers` array key in `config/app.php` and register the **Geocoder Service Provider**. | ||
|
||
### Geocoding Addresses | ||
#### Get Collection of Addresses | ||
```php | ||
'providers' => array( | ||
// ... | ||
|
||
Toin0u\Geocoder\GeocoderServiceProvider::class, | ||
) | ||
app('geocoder')->geocode('Los Angeles, CA')->get(); | ||
``` | ||
|
||
Find the `aliases` array key in `config/app.php` and register the **Geocoder Facade**. | ||
|
||
#### Get Array of Addresses | ||
```php | ||
'aliases' => array( | ||
// ... | ||
|
||
'Geocoder' => Toin0u\Geocoder\Facade\Geocoder::class, | ||
) | ||
app('geocoder')->geocode('Los Angeles, CA')->all(); | ||
``` | ||
|
||
Configuration | ||
------------- | ||
|
||
Publish and edit the configuration file | ||
|
||
```bash | ||
$ php artisan vendor:publish --provider="toin0u/geocoder-laravel" | ||
``` | ||
|
||
The service provider creates the following services: | ||
|
||
* `geocoder`: the Geocoder instance. | ||
* `geocoder.chain`: the chain provider used by Geocoder. | ||
* `geocoder.adapter`: the HTTP adapter used to get data from remotes APIs. | ||
|
||
By default, the `geocoder.chain` service contains `GoogleMapsProvider` and `FreeGeoIpProvider`. | ||
The `geocoder.adapter` service uses the cURL adapter. Override these services to use the | ||
adapter/providers you want by editing `config/geocoder.php`: | ||
|
||
#### Reverse-Geocoding | ||
```php | ||
return [ | ||
'providers' => [ | ||
'\Geocoder\Provider\GoogleMapsProvider' => ['en_EN', 'my-region', $ssl = false, 'MY_API_KEY'], | ||
'\Geocoder\Provider\GoogleMapsBusinessProvider' => ['my-locale', 'my-region', $ssl = true, 'MY_API_KEY'], | ||
], | ||
'adapter' => '\Geocoder\HttpAdapter\CurlHttpAdapter' | ||
]; | ||
app('geocoder')->reverse(43.882587,-103.454067)->get(); | ||
``` | ||
|
||
NB: As you can see the array value of the provider is the constructor arguments. | ||
|
||
See [the Geocoder documentation](http://geocoder-php.org/Geocoder/) for a list of available adapters and providers. | ||
|
||
|
||
Example with Facade | ||
------------------- | ||
|
||
#### Dumping Results | ||
```php | ||
<?php | ||
|
||
// ... | ||
try { | ||
$geocode = Geocoder::geocode('10 rue Gambetta, Paris, France'); | ||
// The GoogleMapsProvider will return a result | ||
var_dump($geocode); | ||
} catch (\Exception $e) { | ||
// No exception will be thrown here | ||
echo $e->getMessage(); | ||
} | ||
app('geocoder')->geocode('Los Angeles, CA')->dump('kml'); | ||
``` | ||
|
||
## Changelog | ||
https://github.com/geocoder-php/GeocoderLaravel/blob/master/CHANGELOG.md | ||
|
||
Changelog | ||
--------- | ||
|
||
[See the CHANGELOG file](https://github.com/geocoder-php/GeocoderLaravel/blob/master/CHANGELOG.md) | ||
|
||
|
||
Support | ||
------- | ||
|
||
[Please open an issue on GitHub](https://github.com/geocoder-php/GeocoderLaravel/issues) | ||
|
||
|
||
Contributor Code of Conduct | ||
--------------------------- | ||
|
||
Please note that this project is released with a Contributor Code of Conduct. | ||
By participating in this project you agree to abide by its terms. | ||
|
||
## Support | ||
If you are experiencing difficulties, please please open an issue on GitHub: | ||
https://github.com/geocoder-php/GeocoderLaravel/issues. | ||
|
||
License | ||
------- | ||
## Contributor Code of Conduct | ||
Please note that this project is released with a | ||
[Contributor Code of Conduct](https://github.com/geocoder-php/Geocoder#contributor-code-of-conduct). | ||
By participating in this project you agree to abide by its terms. | ||
|
||
## License | ||
GeocoderLaravel is released under the MIT License. See the bundled | ||
[LICENSE](https://github.com/geocoder-php/GeocoderLaravel/blob/master/LICENSE) | ||
file for details. | ||
[LICENSE](https://github.com/geocoder-php/GeocoderLaravel/blob/master/LICENSE) | ||
file for details. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more non-coding remark: I found the previous version not readable, but I still find the new version complicated. I would use lists of short sentences (and no section).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend you not to change everything as the existing project's layout was pretty the same as the other projects in the Geocoder org. Yet, feel free to make the changes you wish, but you're not alone ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I structure CHANGELOG files this way is to adhere to the suggested conventions established at http://keepachangelog.com/en/0.3.0/. It enables not only humans to read it as a markdown document, but for systems to analyze it and work with it in a structured manner. I know there isn't a stndard, but I like to adhere to this recommendation in all my packages. If you feel this is not a good direction, I will revert this back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a good point. Let's use your structure then!