|
| 1 | +Geocoder for Lavarel 4 |
| 2 | +====================== |
| 3 | + |
| 4 | +This package allows you to use [**Geocoder**](http://geocoder-php.org/Geocoder/) |
| 5 | +in [**Laravel 4**](http://laravel.com/). |
| 6 | + |
| 7 | + |
| 8 | +Installation |
| 9 | +------------ |
| 10 | + |
| 11 | +It can be found on [Packagist](https://packagist.org/packages/toin0u/geocoder-laravel). |
| 12 | +The recommended way is through [composer](http://getcomposer.org). |
| 13 | + |
| 14 | +Edit `compose.json` and add: |
| 15 | + |
| 16 | +```json |
| 17 | +{ |
| 18 | + "require": { |
| 19 | + "toin0u/geocoder-laravel": "~0.1" |
| 20 | + } |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +And install dependencies: |
| 25 | + |
| 26 | +```bash |
| 27 | +$ curl -sS https://getcomposer.org/installer | php |
| 28 | +$ php composer.phar install |
| 29 | +``` |
| 30 | + |
| 31 | + |
| 32 | +Usage |
| 33 | +----- |
| 34 | + |
| 35 | +Find the `providers` key in `app/config/app.php` and register the **Geocoder Service Provider**. |
| 36 | + |
| 37 | +```php |
| 38 | +'providers' => array( |
| 39 | + // ... |
| 40 | + |
| 41 | + 'Toin0u\Geocoder\GeocoderServiceProvider', |
| 42 | +) |
| 43 | +``` |
| 44 | + |
| 45 | +Find the `aliases` key in `app/config/app.php` and register the **Geocoder Facade**. |
| 46 | + |
| 47 | +```php |
| 48 | +'aliases' => array( |
| 49 | + // ... |
| 50 | + |
| 51 | + 'Geocoder' => 'Toin0u\Geocoder\GeocoderFacade', |
| 52 | +) |
| 53 | +``` |
| 54 | + |
| 55 | +Configuration |
| 56 | +------------- |
| 57 | + |
| 58 | +The service provider creates the following services: |
| 59 | + |
| 60 | + * `geocoder`: the Geocoder instance. |
| 61 | + * `geocoder.provider`: the provider used by Geocoder. |
| 62 | + * `geocoder.adapter`: the HTTP adapter used to get data from remotes APIs. |
| 63 | + |
| 64 | +By default, the `geocoder.provider` service uses FreeGeoIP and the `geocoder.adapter` service uses the cURL adapter. |
| 65 | +Override these services to use the adapter/provider you want. |
| 66 | + |
| 67 | +See [the Geocoder documentation](http://geocoder-php.org/Geocoder/) for a list of available adapters and providers. |
| 68 | + |
| 69 | + |
| 70 | +Example with Facade |
| 71 | +------------------- |
| 72 | + |
| 73 | +```php |
| 74 | +<?php |
| 75 | + |
| 76 | +// ... |
| 77 | +try { |
| 78 | + $geocode = Geocoder::geocode('10 rue Gambetta, Paris, France'); |
| 79 | + // ... |
| 80 | +} catch (\Exception $e) { |
| 81 | + echo $e->getMessage(); |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | + |
| 86 | +Changelog |
| 87 | +--------- |
| 88 | + |
| 89 | +[See the changelog file](https://github.com/toin0u/Geocoder-laravel/blob/master/CHANGELOG.md) |
| 90 | + |
| 91 | + |
| 92 | +Support |
| 93 | +------- |
| 94 | + |
| 95 | +[Please open an issues in github](https://github.com/toin0u/Geocoder-laravel/issues) |
| 96 | + |
| 97 | + |
| 98 | +License |
| 99 | +------- |
| 100 | + |
| 101 | +Geocoder-laravel is released under the MIT License. See the bundled |
| 102 | +[LICENSE](https://github.com/toin0u/Geocoder-laravel/blob/master/LICENSE) file for details. |
0 commit comments