PHPackages                             salvaworld/laravel-spatial - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. salvaworld/laravel-spatial

ActiveLibrary[Database &amp; ORM](/categories/database)

salvaworld/laravel-spatial
==========================

Spatial data types extension for Laravel.

v1.0.4(1y ago)01.2kMITPHPPHP ^7.1|^8.0|^8.1|^8.2

Since Jan 3Pushed 1y agoCompare

[ Source](https://github.com/Salvaworld/laravel-spatial)[ Packagist](https://packagist.org/packages/salvaworld/laravel-spatial)[ RSS](/packages/salvaworld-laravel-spatial/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (8)Used By (0)

Laravel Spatial extension
=========================

[](#laravel-spatial-extension)

[![](https://camo.githubusercontent.com/129882b0cfe9711ffd9c0ebcd7ec005d0dc74dba614df7a32882ad40d6f31aea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64616e68756e73616b65722f6c61726176656c2d7370617469616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danhunsaker/laravel-spatial)[![](https://camo.githubusercontent.com/b6ee8182ea8025e255e5b99b1bde0def89c2bf07cb4cd501c94e7e78d0b31347/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64616e68756e73616b65722f6c61726176656c2d7370617469616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danhunsaker/laravel-spatial)[![](https://camo.githubusercontent.com/274099c02556354884ae30e0ff97bc8b3fc7589dca82a1d3966fa79ffd860870/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616e68756e73616b65722f6c61726176656c2d7370617469616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danhunsaker/laravel-spatial)[![](https://camo.githubusercontent.com/ca220f5e238329491b1c2e42a79509da5a179bf3b47c440663d545218c0fa5ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64616e68756e73616b65722f6c61726176656c2d7370617469616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danhunsaker/laravel-spatial)

[![](https://camo.githubusercontent.com/5256b6b215b0eb110290b74ebb3dd91b26060a62bbc036f0202b72af2533e2de/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f64616e68756e73616b65722f6c61726176656c2d7370617469616c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/danhunsaker/laravel-spatial)[![](https://camo.githubusercontent.com/cefa39b56d46f412a11c019497ccd72007ad56f2607f5f95887fee52369aee4d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f64616e68756e73616b65722f6c61726176656c2d7370617469616c2e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/danhunsaker/laravel-spatial)[![](https://camo.githubusercontent.com/3efdfd2a7178c14fb96568fb2b0f4c1b3e33020e8289220bf86e63a2c1396369/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f64616e68756e73616b65722f6c61726176656c2d7370617469616c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/danhunsaker/laravel-spatial/)

This package is fully undocumented and unstable, and is a combination of the two great packages:

- [Laravel PostGIS extension](https://github.com/njbarrett/laravel-postgis)
- [Laravel MySQL spatial extension](https://github.com/grimzy/laravel-mysql-spatial)

Installation
------------

[](#installation)

Installation made super-easy with [composer](https://getcomposer.org):

```
composer require salvaworld/laravel-spatial
```

Requirements
------------

[](#requirements)

Works with [PostgreSQL](https://www.postgresql.org) installed [PostGIS](http://postgis.net) extension and [MySQL](http://mysql.com) at least version 5.6.

If you try using it on a shared host which is not fulfilling those requirements, change your provider.

Usage
-----

[](#usage)

### Migrations

[](#migrations)

Add spatial fields to your migrations the same way you would any others:

```
    $table->point('point_column');
    $table->linestring('line_string_column');
    $table->polygon('polygon_column');
    $table->geometry('geometry_column');

    $table->multipoint('multi_point_column');
    $table->multilinestring('multi_line_string_column');
    $table->multipolygon('multi_polygon_column');
    $table->geometrycollection('geometry_collection_column');
```

### Models

[](#models)

Any models that use spatial fields need to use the `LaravelSpatial\Eloquent\SpatialTrait`, and list the spatial fields themselves in the `$spatialFields` property:

```
use LaravelSpatial\Eloquent\SpatialTrait;

// ...

class MyModel extends Model
{
    use SpatialTrait;

    // ...

    protected $spatialFields = ['location'];

    // ...
}
```

### Values

[](#values)

We use the [GeoJson PHP Library](http://jmikola.github.io/geojson/) for describing spatial fields as GeoJSON object, e.g.:

```
use GeoJSON\Geometry\Point;

// ...

$eloquent = new MyModel();
$eloquent->location = new Point([49.7, 6.9]);

// ...

$eloquent->save();
```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~346 days

Recently: every ~420 days

Total

7

Last Release

607d ago

Major Versions

v0.1.0 → v1.0.02020-02-05

v0.1.1 → v1.0.12020-07-30

PHP version history (3 changes)v0.1.0PHP ^5.6.4|^7.0

v1.0.0PHP ^7.2

v1.0.2PHP ^7.1|^8.0|^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ffda357df570f6fb3b552b72e5b7af7e65d0a92b16372bebf063d4c8f133384?d=identicon)[salvaworld](/maintainers/salvaworld)

---

Top Contributors

[![danhunsaker](https://avatars.githubusercontent.com/u/1534396?v=4)](https://github.com/danhunsaker "danhunsaker (7 commits)")[![MhmdFneish](https://avatars.githubusercontent.com/u/95351370?v=4)](https://github.com/MhmdFneish "MhmdFneish (4 commits)")[![garret-gunter](https://avatars.githubusercontent.com/u/8146238?v=4)](https://github.com/garret-gunter "garret-gunter (2 commits)")[![abdulkader-freij](https://avatars.githubusercontent.com/u/70880016?v=4)](https://github.com/abdulkader-freij "abdulkader-freij (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/salvaworld-laravel-spatial/health.svg)

```
[![Health](https://phpackages.com/badges/salvaworld-laravel-spatial/health.svg)](https://phpackages.com/packages/salvaworld-laravel-spatial)
```

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[tpetry/laravel-postgresql-enhanced

Support for many missing PostgreSQL specific features

9982.0M14](/packages/tpetry-laravel-postgresql-enhanced)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[limenet/laravel-mysql-spatial

MySQL spatial data types extension for Laravel.

1214.2k](/packages/limenet-laravel-mysql-spatial)[ntanduy/cloudflare-d1-database

Easy configuration and setup for D1 Database connections in Laravel.

215.4k](/packages/ntanduy-cloudflare-d1-database)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
