Skip to content

Commit

Permalink
Merge branch 'master' of github.com:geocoder-php/GeocoderLaravel
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebronner committed Oct 27, 2017
2 parents 0684b38 + 7bbf368 commit 488cd65
Showing 1 changed file with 86 additions and 77 deletions.
163 changes: 86 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,79 +34,16 @@ This package allows you to use [**Geocoder**](http://geocoder-php.org/Geocoder/)
Geocoder\Laravel\Providers\GeocoderService::class,
// ];
```

## Upgrading
Anytime you upgrade this package, please remember to clear your cache, to prevent incompatible cached responses when breaking changes are introduced (this should hopefully only be necessary in major versions):
```sh
php artisan cache:clear
```

### 1.x to 4.x
Update your composer.json file:
3. **Optional** I recommend adding the following lines to your `composer.json` file to prevent stale caches when upgrading or updating the package, both in your live and dev environments:
```json
"toin0u/geocoder-laravel": "^4.0",
"post-update-cmd": [
"@php artisan cache:clear",
],
"post-install-cmd": [
"@php artisan cache:clear",
]
```

The one change to keep in mind here is that the results returned from
`Geocoder for Laravel` are now using the Laravel-native Collections class
instead of returning an instance of `AddressCollection`. This should provide
greater versatility in manipulation of the results, and be inline with
expectations for working with Laravel. The existing `AddressCollection`
methods should map strait over to Laravel's `Collection` methods. But be sure
to double-check your results, if you have been using `count()`,
`first()`, `isEmpty()`, `slice()`, `has()`, `get()`, or `all()` on your results.
Also, `getProviders()` now returns a Laravel Collection instead of an array.
**Alert:** if you have been using the `getIterator()` method, it is no longer
needed. Simply iterate over your results as you would any other Laravel
collection.
**Deprecated:**
- the `all()` method on the geocoder is being deprecated in favor of using
`get()`, which will return a Laravel Collection. You can then run `all()`
on that. This method will be removed in version 5.0.0.
- the `getProvider()` method on the geocoder is being deprecated in favor of using
`getProviders()`, which will return a Laravel Collection. You can then run `first()`
on that to get the same result. This method will be removed in version 5.0.0.
**Added:** this version introduces a new way to create more complex queries:
- geocodeQuery()
- reverseQuery()
Please see the [Geocoder documentation](https://github.com/geocoder-php/Geocoder)
for more details.
### 0.x to 1.x
If you are upgrading from a pre-1.x version of this package, please keep the
following things in mind:
1. Update your composer.json file as follows:
```json
"toin0u/geocoder-laravel": "^1.0",
```
2. Remove your `config/geocoder.php` configuration file. (If you need to customize it, follow the configuration instructions below.)
3. Remove any Geocoder alias in the aliases section of your `config/app.php`. (This package auto-registers the aliases.)
4. Update the service provider entry in your `config/app.php` to read:
```php
Geocoder\Laravel\Providers\GeocoderService::class,
```
5. If you are using the facade in your code, you have two options:
1. Replace the facades `Geocoder::` (and remove the corresponding `use` statements) with `app('geocoder')->`.
2. Update the `use` statements to the following:
```php
use Geocoder\Laravel\Facades\Geocoder;
```
6. Update your query statements to use `->get()` (to retrieve a collection of
GeoCoder objects) or `->all()` (to retrieve an array of arrays), then iterate
to process each result.
## 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
Expand All @@ -119,8 +56,7 @@ Further, a special note on the GoogleMaps provider: if you are using an API key,
See the [Geocoder documentation](http://geocoder-php.org/Geocoder/) for a list
of available adapters and providers.

### Configuration
#### Providers
### Providers
If you are upgrading and have previously published the geocoder config file, you
need to add the `cache-duration` variable, otherwise cache will be disabled
(it will default to a `0` cache duration). The default cache duration provided
Expand Down Expand Up @@ -165,7 +101,7 @@ return [
];
```

#### Adapters
### Adapters
By default we provide a CURL adapter to get you running out of the box.
However, if you have already installed Guzzle or any other PSR-7-compatible
HTTP adapter, you are encouraged to replace the CURL adapter with it. Please
Expand Down Expand Up @@ -204,12 +140,85 @@ app('geocoder')->reverse(43.882587,-103.454067)->get();
app('geocoder')->geocode('Los Angeles, CA')->dump('kml');
```

## Changelog
https://github.com/geocoder-php/GeocoderLaravel/blob/master/CHANGELOG.md
## Upgrading
Anytime you upgrade this package, please remember to clear your cache, to prevent incompatible cached responses when breaking changes are introduced (this should hopefully only be necessary in major versions):
```sh
php artisan cache:clear
```

## Support
If you are experiencing difficulties, please please open an issue on GitHub:
### 1.x to 4.x
Update your composer.json file:
```json
"toin0u/geocoder-laravel": "^4.0",
```

The one change to keep in mind here is that the results returned from
`Geocoder for Laravel` are now using the Laravel-native Collections class
instead of returning an instance of `AddressCollection`. This should provide
greater versatility in manipulation of the results, and be inline with
expectations for working with Laravel. The existing `AddressCollection`
methods should map strait over to Laravel's `Collection` methods. But be sure
to double-check your results, if you have been using `count()`,
`first()`, `isEmpty()`, `slice()`, `has()`, `get()`, or `all()` on your results.
Also, `getProviders()` now returns a Laravel Collection instead of an array.
**Alert:** if you have been using the `getIterator()` method, it is no longer
needed. Simply iterate over your results as you would any other Laravel
collection.
**Deprecated:**
- the `all()` method on the geocoder is being deprecated in favor of using
`get()`, which will return a Laravel Collection. You can then run `all()`
on that. This method will be removed in version 5.0.0.
- the `getProvider()` method on the geocoder is being deprecated in favor of using
`getProviders()`, which will return a Laravel Collection. You can then run `first()`
on that to get the same result. This method will be removed in version 5.0.0.
**Added:** this version introduces a new way to create more complex queries:
- geocodeQuery()
- reverseQuery()
Please see the [Geocoder documentation](https://github.com/geocoder-php/Geocoder)
for more details.
### 0.x to 1.x
If you are upgrading from a pre-1.x version of this package, please keep the
following things in mind:
1. Update your composer.json file as follows:
```json
"toin0u/geocoder-laravel": "^1.0",
```
2. Remove your `config/geocoder.php` configuration file. (If you need to customize it, follow the configuration instructions below.)
3. Remove any Geocoder alias in the aliases section of your `config/app.php`. (This package auto-registers the aliases.)
4. Update the service provider entry in your `config/app.php` to read:
```php
Geocoder\Laravel\Providers\GeocoderService::class,
```
5. If you are using the facade in your code, you have two options:
1. Replace the facades `Geocoder::` (and remove the corresponding `use` statements) with `app('geocoder')->`.
2. Update the `use` statements to the following:
```php
use Geocoder\Laravel\Facades\Geocoder;
```
6. Update your query statements to use `->get()` (to retrieve a collection of
GeoCoder objects) or `->all()` (to retrieve an array of arrays), then iterate
to process each result.
## Troubleshooting
- Clear cache: `php artisan cache:clear`.
- If you are still experiencing difficulties, please please open an issue on GitHub:
https://github.com/geocoder-php/GeocoderLaravel/issues.
## Changelog
https://github.com/geocoder-php/GeocoderLaravel/blob/master/CHANGELOG.md
## Contributor Code of Conduct
Please note that this project is released with a
Expand Down

0 comments on commit 488cd65

Please sign in to comment.