Download the PHP package netsells/laravel-geoscope without Composer

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

Laravel GeoScope

GeoScope is a laravel package that allows you to easily perform distance queries and geofencing based on latitudes and longitudes.

It is created and maintained by the Netsells team

Key Features

Installation

using composer:

Then publish the config file using the following artisan command:

Usage

Basic Usage

GeoScope includes the Netsells\GeoScope\Traits\GeoScopeTrait that can be added to your models. The trait contains two scopes, withinDistanceOf and orWithinDistanceOf. withinDistanceOf will add a where clause to your query and orWithinDistanceOf will add an orWhere. Both of these methods accept 3 parameters, a latitude, longitude and distance. Both the latitude and longitude should be given in degrees. GeoScope with then use these to query against the specified lat long fields on that model.

the scopes can then be applied to any model query:

GeoScope also includes an orderByDistanceFrom() method that allows you to sort results by their distance from a specified lat long.

A field can be added to each returned result with the calculated distance from the given lat long using the addDistanceFromField() method.

before addDistanceFromField() is applied

After addDistanceFromField() is applied

A custom field name can be passed as the third argument to the addDistanceFromField() method if the name has been registered in the whitelisted-distance-from-field-names array of the geoscope.php config file. The distance field will have a default name of distance and the units field will have a default name of distance_units.

The addDistanceFromField() method is only available through the GeoScopeTrait. It is not available on the database builder

Configuration

When adding the GeoScopeTrait to your model you can define the latitude, longitude and distance units to be used by the trait in the geoscope.php config file.

Should you wish to use the scope for multiple latitude and longitude columns on the same model you can do so by creating multiple configurations within the same model key.

The key for the model config you wish to use can then be passed as a fourth parameter to both the withinDistanceOf and orWithinDistanceOf scopes.

You may also pass in an array of config items as the fourth parameter to both the withinDistanceOf and orWithinDistanceOf scopes.

Any missing config options will be replaced with the defaults defined in config('geoscope.defaults'). Passing invalid config keys will also cause GeoScope to fallback to these defaults for all config fields.

Database Query Builder

Geoscope also allows you to call the withinDistanceOf(), orWithinDistanceOf() and orderByDistanceFrom() methods directly off the DB query builder:

if you wish to alter the config options then you may pass an array as the fourth parameter to the withinDistanceOf() and orWithinDistanceOf() methods:

order by distance example:

Scope Drivers

Under the hood, GeoScope uses different drivers to ensure that the distance queries are optimised to the database connection being used. Scope drivers correspond to the database drivers used by Laravel. GeoScope will automatically detect the database driver being used by Laravel and choose the correct scope driver for it. Out of the box GeoScope includes a MySQL scope driver which uses ST_Distance_Sphere() function, a PostgreSQL scope driver which uses earth_distance and a SQL Server driver which uses STDistance.

NOTE: The PostgreSQL driver requires you to have the postgres earthdistance module installed which can be done by executing the following SQL

Creating Custom Scope Drivers

GeoScope allows you to define and register custom scope drivers. To create a custom scope driver create a class that extends Netsells\GeoScope\ScopeDrivers\AbstractScopeDriver . The new driver must then implement the methods outlined in Netsells\GeoScope\Interfaces\ScopeDriverInterface (below).

The Query Builder instance is available within your driver via the $this->query property, any config options passed will be available via the $this->config property.

Registering Custom Scope Drivers

Custom scope drivers can be registered using the registerDriverStrategy method on the ScopeDriverFactory class. Registration should normally be done within the register method of a service provider.

You may set an optional scope-driver config key if you wish to force a specific scope driver to be used.

Note - If you're using MariaDB then you MUST set the scope-driver field to mariadb. This is due to Laravel using the same db connection settings for both Mariadb and MySQL and therefore the db connection cannot be used to distinguish the two.

If you create a custom scope driver, please consider putting in a pull Request to add it to the package so it may be used by others.

Scope Driver Security

Due to the nature of the queries being run by GeoScope, both the whereRaw() and orWhereRaw methods are used. The drivers included by default protect against sql injection attacks (using prepared statements and by checking for valid lat long column config values). It is important that when creating custom scope drivers, that you also take this into consideration for any user input that you pass directly to it.


All versions of laravel-geoscope with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
laravel/framework Version >=5.3
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 netsells/laravel-geoscope contains the following files

Loading the files please wait ....