Download the PHP package astrogin/laravel-mysql-spatial without Composer
On this page you can find all versions of the php package astrogin/laravel-mysql-spatial. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download astrogin/laravel-mysql-spatial
More information about astrogin/laravel-mysql-spatial
Files in astrogin/laravel-mysql-spatial
Package laravel-mysql-spatial
Short Description MySQL spatial data types extension for Laravel.
License MIT
Informations about the package laravel-mysql-spatial
Laravel MySQL Spatial extension
Laravel package to easily work with MySQL Spatial Data Types and MySQL Spatial Functions.
Please check the documentation for your MySQL version. MySQL's Extension for Spatial Data was added in MySQL 5.5 but many Spatial Functions were changed in 5.6 and 5.7.
Installation
Add the package using composer:
Register the service provider in config/app.php
:
Quickstart
Create a migration
From the command line:
Then edit the migration you just created by adding at least one spatial data field:
Run the migration:
Create a model
From the command line:
Then edit the model you just created. It must use the SpatialTrait
and define an array called $spatialFields
with the name of the MySQL Spatial Data field(s) created in the migration:
Saving a model
Retrieving a model
Migration
Available MySQL Spatial Types migration blueprints:
- geometry
- point
- lineString
- polygon
- multiPoint
- multiLineString
- multiPolygon
- geometryCollection
Spatial index
You can add or drop spatial indexes in your migrations with the spatialIndex
and dropSpatialIndex
blueprints.
Note about spatial indexes from the MySQL documentation:
For
MyISAM
and (as of MySQL 5.7.5)InnoDB
tables, MySQL can create spatial indexes using syntax similar to that for creating regular indexes, but using theSPATIAL
keyword. Columns in spatial indexes must be declaredNOT NULL
.
From the command line:
Then edit the migration you just created:
Models
Available geometry classes:
- Point
- LineString
- Polygon
- MultiPoint
- MultiLineString
- MultiPolygon
- GeometryCollection
Credits
Originally inspired from njbarrett's Laravel postgis package.
All versions of laravel-mysql-spatial with dependencies
illuminate/database Version ^5.2
geo-io/wkb-parser Version ^1.0
jmikola/geojson Version ^1.0