This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

A geospatial library and set of utilities for Laravel

dev-master / 1.0.x-dev 2017-07-22 22:22 UTC

This package is auto-updated.

Last update: 2021-09-29 01:55:16 UTC


LaraGis provides geospatial database and Eloquent features to Laravel.


  • Simple Entity API, for use in casting model properties
  • Fast serialization of geospatial data from MySql (not PHP userland) via ST_AsGeoJSON()


To get started with Socialite, add to your composer.json file as a dependency:

composer require ralphschindler/laragis


After installing the Socialite library, register the LaraGis\LaraGisProvider in your config/app.php configuration file:

'providers' => [
    // Other service providers...


Basic Usage

To use in Eloquent based models, use the LaraGisTrait, and specify a column to be cast into a geospatial datatype with the laragis key in the $casts array:

class Place extends Model
    use LaraGisTrait;

    protected $table = 'places';

    protected $casts = [
        'coordinates' => 'laragis'
$place = App\Places::find(1);
$coordinates = $place->coordinates;
echo $coordinates->getLatitudeLongitude(); // "30, -90"

Entity API

 * @property double $latitude
 * @property double $longitude
class Coordinates {
    public function __construct($latitude = null, $longitude = null);
    public function setLatitude($latitude);
    public function getLatitude();
    public function setLongitude($longitude);
    public function getLongitude();
    public function castToString($separator, $coordinatesOrder = self::LATITUDE_FIRST)

class Area implements \IteratorAggregate, \Countable {
    public function addCoordinates(Coordinates $coordinates);
    public function getCoordinates();