Skip to content

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 28 commits into from
Oct 14, 2016
Merged
Show file tree
Hide file tree
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 Sep 30, 2016
3f1d8b6
Updated config
mikebronner Sep 30, 2016
34b6148
Merged branch master into feature/update-for-laravel-5-3
mikebronner Sep 30, 2016
4b89847
Merged branch master into master
mikebronner Sep 30, 2016
7f857c7
Update publish command in readme
mikebronner Sep 30, 2016
4cab9bc
Merged branch master into feature/update-for-laravel-5-3
mikebronner Sep 30, 2016
a6d9e34
Re-arrange tests, make sure IP addresses are geocoded.
mikebronner Oct 1, 2016
245ff56
Implement fix for specialized providers
mikebronner Oct 1, 2016
4926302
Implement multiple providers
mikebronner Oct 1, 2016
1b25952
Refactor and clean up the service provider
mikebronner Oct 1, 2016
f115148
Create chainable provider with dump functionality
mikebronner Oct 1, 2016
379682d
Update tests
mikebronner Oct 1, 2016
31d1819
Update documentation, changelog, change namespace
mikebronner Oct 1, 2016
7050192
Fix namespaces in README
mikebronner Oct 1, 2016
964d30c
Fix examples in readme
mikebronner Oct 1, 2016
4a4e152
Remove erroneous use statement from readme
mikebronner Oct 1, 2016
8f07737
Implement stand-along package tests
mikebronner Oct 1, 2016
c4b423c
Update travis config
mikebronner Oct 2, 2016
cfd14a7
Update composer.json
mikebronner Oct 3, 2016
49e32f9
WIP - configuring PHPCI
mikebronner Oct 4, 2016
00bedff
Fix phpci config filename
mikebronner Oct 4, 2016
e01edb8
WIP - getting PHPCI to respect configuration
mikebronner Oct 4, 2016
c63423e
WIP - remove phpci config file, update readme with build status icon …
mikebronner Oct 4, 2016
6c4ac31
Improve quality of some of the integration tests
mikebronner Oct 5, 2016
1f35c25
Update phpunit config and add link to code coverage
mikebronner Oct 5, 2016
b46213e
Fix autoload declaration
mikebronner Oct 5, 2016
9ce156f
Add travis config file back in
mikebronner Oct 14, 2016
090bc89
Place namespace declaration below file comment
mikebronner Oct 14, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 51 additions & 28 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,64 @@
CHANGELOG
=========
# Geocoder for Laravel Changelog
Copy link
Member

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).

Copy link
Member

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 ;-)

Copy link
Member Author

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.

Copy link
Member

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!

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.
218 changes: 98 additions & 120 deletions README.md
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/).

[![Latest StableVersion](https://poser.pugx.org/toin0u/geocoder-laravel/v/stable.png)](https://packagist.org/packages/toin0u/geocoder-laravel)
[![Total Downloads](https://poser.pugx.org/toin0u/geocoder-laravel/downloads.png)](https://packagist.org/packages/toin0u/geocoder-laravel)
[![Build Status](https://secure.travis-ci.org/geocoder-php/GeocoderLaravel.png)](http://travis-ci.org/geocoder-php/GeocoderLaravel)
[![Coverage Status](https://coveralls.io/repos/geocoder-php/GeocoderLaravel/badge.png)](https://coveralls.io/r/geocoder-php/GeocoderLaravel)

[![Build Status](https://ci.genealabs.com/build-status/image/1)](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.
Loading