Skip to content

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
wants to merge 19 commits into from
Closed
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions .travis.yml
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
102 changes: 61 additions & 41 deletions CHANGELOG.md
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\...`.
Copy link
Member

@willdurand willdurand Oct 2, 2016

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

Copy link
Member Author

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?

- 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.
214 changes: 96 additions & 118 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)

# 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.
Loading