-
Notifications
You must be signed in to change notification settings - Fork 106
Updating for Laravel 5.3 #48
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
Closed
mikebronner
wants to merge
19
commits into
geocoder-php:master
from
GeneaLabs:feature/update-for-laravel-5-3
+646
−430
Closed
Changes from all commits
Commits
Show all changes
19 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 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,16 +1,13 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
- 5.5 | ||
- 5.6 | ||
- 7.0 | ||
- hhvm | ||
|
||
before_script: | ||
- travis_retry composer self-update | ||
- travis_retry composer install --no-interaction --prefer-source --dev | ||
|
||
script: phpunit --coverage-text --coverage-clover ./build/logs/clover.xml | ||
script: vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml | ||
|
||
after_script: php vendor/bin/coveralls |
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,61 @@ | ||
CHANGELOG | ||
========= | ||
|
||
0.5.0 (2015-03-11) | ||
------------------ | ||
|
||
* [BC] the package is now compatible for Laravel 5 | ||
* improved the doc | ||
* add code of conduct | ||
|
||
0.4.1 (2014-06-23) | ||
------------------ | ||
|
||
* fix the way to implode provider's arguments + unit tests | ||
|
||
0.4.0 (2014-04-13) | ||
------------------ | ||
|
||
* use Geocoder 2.4.* | ||
|
||
|
||
0.3.0 (2014-04-13) | ||
------------------ | ||
|
||
* support provider's arugments (BC break) | ||
|
||
|
||
0.2.0 (2013-11-16) | ||
------------------ | ||
|
||
* use Geocoder 2.3.x | ||
* use config file | ||
* use singleton instead of share | ||
* improve tests | ||
|
||
|
||
0.1.0 (2013-09-16) | ||
------------------ | ||
|
||
* add badges | ||
* initial import | ||
# 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.7.0] - 1 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. | ||
|
||
### 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. | ||
|
||
### Fixed | ||
- MaxMindBinary Provider being instantiated with an Adapter #24. | ||
- GeoIP2 Provider being instantiated with a generic Adapter. | ||
|
||
## [0.6.0] | ||
- TBD | ||
|
||
## [0.5.0] - 11 Mar 2015 | ||
### Added | ||
- code of conduct message. | ||
- Laravel 5 compatibility [BC]. | ||
|
||
### Updated | ||
- documentation. | ||
|
||
## [0.4.1] - 23 Jun 2014 | ||
### Fixed | ||
- the way to implode provider's arguments + unit tests. | ||
|
||
## [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] - 16 Nov 2013 | ||
### Added | ||
- config file. | ||
|
||
### Updated | ||
- to use Geocoder 2.3.x. | ||
- to use singleton instead of share. | ||
- tests. | ||
|
||
## [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) | ||
|
||
# Geocoder for Lavarel | ||
|
||
Installation | ||
------------ | ||
|
||
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 0.7.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.
Uh oh!
There was an error while loading. Please reload this page.
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.
then, let's use 1.0.0 as version, not 0.7.0
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.
Sounds good :) Should we start off with 1.0.0-RC as there are bound to be a few small wrinkles, like code coverage, additional test, and run it in a few projects?