Download the PHP package leitom/geo without Composer
On this page you can find all versions of the php package leitom/geo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package geo
A package that uses Redis geospatial functions for providing super fast searches.
This package makes it easy to add geospatial to your Laravel applications. It uses Redis built in geospatial features and combine this with your Laravel Models in an elegant way.
Installation
You can install the package via composer:
Usage
The package comes with a simple trait thats integrates with Laravel Eloquent models but also a facade to interact with the different geospatial functions.
Laravel Eloquent integration
All you have to do when integrating this package with one or more of your Eloquent models is to use the trait. This trait will take care of keeping the Redis index in sync with your models due to the use of a model observer so you dont have to think about it. Each time you create, save or delete a model the Redis index will be updated to reflect the changes.
Search
Here we perform a search with Longitude, Latitude and Radius. The unit of the radius is configured in the configuration file, default km = kilometers. With the 4. argument to the function you can specify the sorting, default .
The package adds two attributes to every model who implements the HasGeoAbilities. We add the unit and distance wich you can display to the end user.
The function is also overrided so that these two attributes would be loaded.
Find distance between two models
To find the distance between two models you can use the function on a given model
Get the nearest models
Perform a search via the facade
Get the distance between two locations
Get a list of the nearest locations from a given location
Add a coordinate to an index
Add multiple coordinates to an index
Remove coordinates from an index
Import and Remove existing models
The package include two commands to handle import and remove models from the Redis index. This is usefull if you integrate this package in an existing project.
Testing
Ensure you have Redis installed. If you are not using the default configuration for Redis you can change environment variables in the phpunit.xml file.
When testing you own application logic you should include the trait. This will ensure that you start with a fresh Redis index inside your tests. Just like the built in trait in Laravel.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Tommy Leirvik
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.