Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Laravel
  3. Laravel MySQL Spatial extension

Laravel MySQL Spatial extension

NOASSERTIONPHP5.0.0

A Laravel package for working with MySQL Spatial Data Types and Spatial Functions in Eloquent models and migrations.

GitHubGitHub
810 stars334 forks0 contributors

What is Laravel MySQL Spatial extension?

Laravel MySQL Spatial is a Laravel package that integrates MySQL's spatial data extensions into the Laravel ecosystem. It allows developers to use MySQL spatial data types (like points, polygons, and linestrings) and spatial functions directly within Eloquent models and database migrations. This solves the problem of handling geographic data in Laravel applications without relying on external GIS systems.

Target Audience

Laravel developers building applications that require geographic data storage and queries, such as location-based services, mapping tools, or geospatial analytics.

Value Proposition

Developers choose this package because it seamlessly integrates MySQL's spatial capabilities into Laravel's Eloquent ORM and migration system, offering a familiar API for complex geospatial operations. It eliminates the need for raw SQL queries and provides type-safe geometry classes with support for modern standards like GeoJSON.

Overview

MySQL Spatial Data Extension integration with Laravel.

Use Cases

Best For

  • Adding location storage (e.g., coordinates) to Laravel models
  • Building geofencing features with spatial queries (e.g., points within a polygon)
  • Creating mapping applications that require spatial data persistence
  • Performing distance calculations between geographic points in MySQL
  • Managing complex geographic shapes (polygons, linestrings) in Laravel
  • Optimizing spatial queries with indexed spatial columns in migrations

Not Ideal For

  • Projects planning to use PostgreSQL or other non-MySQL databases for spatial data, as the package is MySQL-exclusive.
  • Applications requiring advanced GIS features like 3D geometries or raster support, which MySQL's spatial extensions lack.
  • Teams needing a database-agnostic solution to avoid vendor lock-in or support multiple backends.

Pros & Cons

Pros

Eloquent-Friendly Integration

Seamlessly adds spatial data handling to Laravel models using traits and scopes, making it feel native as described in the philosophy section.

Comprehensive Geometry Classes

Provides PHP classes for all MySQL spatial types with helpers for WKT, GeoJSON, and array operations, simplifying data manipulation and serialization.

Spatial Query Scopes

Includes built-in Eloquent scopes for common spatial analyses like distance, within, and intersects, reducing the need for raw SQL queries.

Migration Blueprint Support

Offers easy-to-use migration methods for creating spatial columns and indexes, facilitating database schema management without manual SQL.

Cons

MySQL-Only Lock-in

The package is tightly coupled to MySQL, preventing the use of more powerful spatial databases like PostGIS and limiting future scalability or database switches.

Version Complexity

With separate branches for different MySQL and Laravel versions, as noted in the README, it adds maintenance overhead and risk of compatibility issues.

Spatial Index Hassles

Setting up spatial indexes requires handling table engine constraints and nullable fields, which can be error-prone and complex, especially for older MySQL versions.

Frequently Asked Questions

Quick Stats

Stars810
Forks334
Contributors0
Open Issues69
Last commit2 years ago
CreatedSince 2017

Tags

#eloquent#database#location-based-services#laravel#geospatial#laravel-5-package#geometry#spatial#gis#migrations#mysql#php#spatial-data

Built With

M
MySQL
C
Composer
P
PHP
L
Laravel

Included in

Laravel13.0k
Auto-fetched 18 hours ago

Related Projects

LiveWireLiveWire

A full-stack framework for Laravel that takes the pain out of building dynamic UIs.

Stars23,556
Forks1,742
Last commit2 days ago
Debug BarDebug Bar

Debugbar for Laravel (Integrates PHP Debug Bar)

Stars19,270
Forks1,617
Last commit14 days ago
IDE HelperIDE Helper

IDE Helper for Laravel

Stars14,953
Forks1,191
Last commit14 days ago
Intervention ImageIntervention Image

PHP Image Processing

Stars14,356
Forks1,495
Last commit5 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub