Download the PHP package jackardios/laravel-eloquent-spatial without Composer

On this page you can find all versions of the php package jackardios/laravel-eloquent-spatial. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-eloquent-spatial

Laravel Eloquent Spatial

Latest Version on Packagist Total Downloads

Laravel package for working with spatial data types and functions in Eloquent.

This package is a fork of matanyadaev/laravel-eloquent-spatial, maintained by Jackardios.

Supported Databases

These are the versions that the tests run on.

Requirements

For PHP 8.1 or 8.2, or Laravel 10, 11 or 12 before 12.18, use version 4.x.

Installation

Quick Start

1. Create a Migration

To restrict a column to one SRID, pass it to the column, for example $table->geometry('location', subtype: 'point', srid: 4326). MySQL 8 then rejects geometries with a different SRID.

2. Set Up Your Model

3. Work with Spatial Data

The geometries that a query compares must have the same SRID, so the examples use SRID 4326 throughout. Without an SRID, a geometry has the default SRID, 0 unless you change it.

Geometry Classes

All geometry classes support creating instances from various formats:

Each method reads only its own format: fromWkt() does not accept GeoJSON, and fromJson() does not accept WKT. Z and M coordinates are read and dropped. Factory::parse() detects which of these formats a string is in. It does not apply the default SRID: the SRID is the one in EWKT, EWKB or the MySQL format, and 0 for WKT and GeoJSON, while fromWkt(), fromJson() and fromArray() use the default SRID.

Available Geometry Types

Class Description
Point Single coordinate (longitude, latitude)
LineString Ordered sequence of Points
Polygon Closed shape defined by LineStrings
MultiPoint Collection of Points
MultiLineString Collection of LineStrings
MultiPolygon Collection of Polygons
GeometryCollection Mixed collection of any geometry types
BoundingBox Rectangular bounds with antimeridian support

Coordinate Validation

The Point class validates coordinates automatically. With SRID 0 (the default) or 4326, the coordinates are degrees:

Other SRIDs have their own units, so their ranges are not checked. With any SRID, the coordinates must be finite:

Spatial Query Scopes

The HasSpatial trait provides query scopes for spatial operations:

Distance Queries

The operator must be one of =, <, >, <=, >=, <> and !=, and the direction asc or desc in any case. Anything else throws InvalidArgumentException, because these arguments are written into the SQL. The alias of withDistance() and withDistanceSphere() is quoted as a column name.

Spatial Relationship Queries

BoundingBox

The BoundingBox class represents rectangular geographic bounds:

BoundingBox as Model Attribute

The geometry is stored with the default SRID unless the cast names one. On MySQL 8, a column with an SRID accepts only geometries with that SRID.

SRID Support

Spatial Reference Identifiers define coordinate systems:

Extending Geometry Classes

Using Macros

Custom Geometry Classes

Parsed and database values are then created as CustomPoint. A Point::class cast accepts it, and GeoJSON and WKB write it as a Point.

Long-running processes (Octane, queue workers)

The classes registered with EloquentSpatial::use*(), the default SRID and macros are static, so they are shared by all requests that a process handles. Set them once in the boot() method of a service provider, never per request.

Dirty Checks

The geometry and bounding box casts compare values themselves, so models detect changes correctly without the HasSpatial trait. A change of only the SRID or only the geometry type, such as a Point replaced by a MultiPoint with the same coordinates, is saved.

Limitations

API Reference

For complete API documentation, see API.md.

Upgrading

See UPGRADE.md for upgrade instructions from previous versions.

Development

License

MIT License. See LICENSE.md for details.


All versions of laravel-eloquent-spatial with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-json Version *
ext-pdo Version *
brick/geo Version ^0.13.1
laravel/framework Version ^12.18|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jackardios/laravel-eloquent-spatial contains the following files

Loading the files please wait ...