PHPackages                             roman-franko/yii2-spatial - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. roman-franko/yii2-spatial

ActiveYii2-extension[Database &amp; ORM](/categories/database)

roman-franko/yii2-spatial
=========================

Yii2 ActiveRecord supporting MySQL spatial data

v1.0.6(9mo ago)044MITPHPPHP &gt;=5.5.0

Since Oct 20Pushed 9mo agoCompare

[ Source](https://github.com/roman-franko/yii2-spatial)[ Packagist](https://packagist.org/packages/roman-franko/yii2-spatial)[ RSS](/packages/roman-franko-yii2-spatial/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (10)Used By (0)

Yii2-spatial
============

[](#yii2-spatial)

ActiveRecord with spatial attributes. Those attributes are transformed from the internal [MySQL format](https://dev.mysql.com/doc/refman/5.5/en/spatial-datatypes.html) to [GeoJSON format](http://geojson.org/geojson-spec.html) 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
------------

[](#installation)

Install **Yii2-spatial** with [Composer](https://getcomposer.org/). 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](https://github.com/sjaakp/yii2-spatial/archive/master.zip).

Usage
-----

[](#usage)

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

```
