Download the PHP package coresmart/laravel-spatial without Composer

On this page you can find all versions of the php package coresmart/laravel-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-spatial

Laravel Spatial

Forked from tarfin-labs/laravel-spatial for laravel 9 support

Latest Version on Packagist Total Downloads GitHub Actions

This is a Laravel package to work with geospatial data types and functions.

It supports only MySQL Spatial Data Types and Functions, other RDBMS is on the roadmap.

Supported data types:

Available Scopes:


Installation

You can install the package via composer:

Usage

Generate a new model with a migration file:

1- Migrations:

To add a spatial data field, you need to extend the migration from TarfinLabs\LaravelSpatial\Migrations\SpatialMigration.

It is a simple abstract class that adds point spatial data type to Doctrine mapped types in the constructor.

The migration above creates an addresses table with a location spatial column.

Spatial columns with no SRID attribute are not SRID-restricted and accept values with any SRID. However, the optimizer cannot use SPATIAL indexes on them until the column definition is modified to include an SRID attribute, which may require that the column contents first be modified so that all values have the same SRID.

So you should give an SRID attribute to use spatial indexes in the migrations:


2- Models:

Fill the $fillable, $casts arrays in the model:

3- Spatial Data Types:

Point:

Point represents the coordinates of a location and contains latitude, longitude, and srid properties.

At this point, it is crucial to understand what SRID is. Each spatial instance has a spatial reference identifier (SRID). The SRID corresponds to a spatial reference system based on the specific ellipsoid used for either flat-earth mapping or round-earth mapping. A spatial column can contain objects with different SRIDs.

For details about SRID you can follow the link: https://en.wikipedia.org/wiki/Spatial_reference_system

You can override the default SRID via the laravel-spatial config file. To do that, you should publish the config file using vendor:publish artisan command:

After that, you can change the value of default_srid in config/laravel-spatial.php


4- Scopes:

withinDistanceTo()

You can use the withinDistanceTo() scope to filter locations by given distance:

To filter addresses within the range of 10 km from the given coordinate:

selectDistanceTo()

You can get the distance between two points by using selectDistanceTo() scope. The distance will be in meters:

orderByDistanceTo()

You can order your models by distance to given coordinates:

Get latitude and longitude of the location:

Create a new address with location:

Testing

Road Map

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-spatial with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/support Version ^8.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 coresmart/laravel-spatial contains the following files

Loading the files please wait ....