Download the PHP package roman-franko/yii2-spatial without Composer

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

Yii2-spatial

ActiveRecord with spatial attributes. Those attributes are transformed from the internal MySQL format to GeoJSON format after finding, and vice versa before storing.

Yii-spatial can also be used to find the model or models which are nearest to a given location.

Notice that this extension is intended to be used with a MySQL or MariaDB database exclusively.

Version 1.1.0 is compatible with MySQL 5.7 and MariaDB 10.3.

Installation

Install Yii2-spatial with Composer. Either add the following to the require section of your composer.json file:

"romanfranko/yii2-spatial": "*"

Or run:

composer require romanfranko/yii2-spatial "*"

You can manually install Yii2-spatial by downloading the source in ZIP-format.

Usage

Simply use a romanfranko\spatial\ActiveRecord as base class for your models, like so:

<?php

use romanfranko\spatial\ActiveRecord;

class MySpatialModel extends ActiveRecord
{
    // ...
}

Notice: if you override find() in a romanfranko\spatial\ActiveRecord-derived class, be sure to return a romanfranko\spatial\ActiveQuery and not an 'ordinary' yii\db\ActiveQuery.

ActiveRecord method

featureProperties()

public function featureProperties($field, $geometry)

Override this function to add properties to the GeoJSON encoded attribute.

The default implementation adds the ActiveRecord's primary key as the property 'id'.

ActiveQuery method

nearest()

public function nearest($from, $attribute, $radius)

Change the query so that it finds the model(s) nearest to the point given by $from.

Example usages:

$here = [4.9, 52.3];     // longitude and latitude of my place

$here2 = '{"type":"Point","coordinates":[4.9,52.3]}';   // another representation

$nearestModel = <model>::find()->nearest($here, <attributeName>, 200)->one();    // search radius is 200 km

$fiveNearestModels =  <model>::find()->nearest($here, <attributeName>)->limit(5)->all();    // search radius is 100 km (default)

$dataProvider = new ActiveDataProvider([ 'query' => <model>::find()->nearest($here, <attributeName>) ]);

Thanks


All versions of yii2-spatial with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.0
yiisoft/yii2 Version *
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 roman-franko/yii2-spatial contains the following files

Loading the files please wait ....