PHPackages                             mythril/doctrine2-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. mythril/doctrine2-spatial

ActiveLibrary

mythril/doctrine2-spatial
=========================

Doctrine2 multi-platform support for spatial types and functions

193PHP

Since Oct 15Pushed 12y ago1 watchersCompare

[ Source](https://github.com/mythril/doctrine2-spatial)[ Packagist](https://packagist.org/packages/mythril/doctrine2-spatial)[ RSS](/packages/mythril-doctrine2-spatial/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (6)Used By (0)

doctrine2-spatial
=================

[](#doctrine2-spatial)

Doctrine2 multi-platform support for spatial types and functions. Currently MySQL and PostgreSQL with PostGIS are supported. Could potentially add support for other platforms if an interest is expressed.

This package is a refactor/continuation of my [doctrine2-mysql-spatial](https://github.com/djlambert/doctrine2-mysql-spatial) package.

Types
-----

[](#types)

The following SQL/OpenGIS types have been implemented as PHP objects and accompanying Doctrine types:

### Geometry

[](#geometry)

- Point
- LineString
- Polygon
- MultiPoint
- MultiLineString
- MultiPolygon

### Geography

[](#geography)

Similar to Geometry but SRID value is always used (SRID supported in PostGIS only), and accepts only valid "geographic" coordinates.

- Point
- LineString
- Polygon

### Planned

[](#planned)

- GeometryCollection
- 3D/4D geometries ??
- Rasters ??????

There is support for both WKB/WKT and EWKB/EWKT return values. Currently only WKT/EWKT is used in statements.

Functions
---------

[](#functions)

Currently the following SQL functions are supported in DQL (more coming):

### PostgreSQL

[](#postgresql)

- ST\_Area
- ST\_AsBinary
- ST\_AsText
- ST\_Centroid
- ST\_ClosestPoint
- ST\_Contains
- ST\_ContainsProperly
- ST\_CoveredBy
- ST\_Covers
- ST\_Crosses
- ST\_Disjoint
- ST\_Distance
- ST\_Envelope
- ST\_GeomFromText
- ST\_Length
- ST\_LineCrossingDirection
- ST\_StartPoint
- ST\_Summary

### MySQL

[](#mysql)

- Area
- AsBinary
- AsText
- Contains
- Disjoint
- Envelope
- GeomFromText
- GLength
- MBRContains
- MBRDisjoint
- StartPoint

DQL AST Walker
--------------

[](#dql-ast-walker)

A DQL AST walker is included which when used with the following DQL functions will return the appropriate Geometry type object from queries instead of strings:

- AsText
- ST\_AsText
- AsBinary
- ST\_AsBinary

EWKT/EWKB function support planned.

### Example:

[](#example)

```
    $query = $this->em->createQuery('SELECT AsText(StartPoint(l.lineString)) MyLineStringEntity l');

    $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'CrEOF\Spatial\ORM\Query\GeometryWalker');

    $result = $query->getResult();

```

`$result[n][1]` will now be of type `Point` instead of the string `'POINT(X Y)'`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0963d1268781bb01967567b04ebb13e72fb7205ec67787801dfc88fdb01974e8?d=identicon)[mythril](/maintainers/mythril)

---

Top Contributors

[![djlambert](https://avatars.githubusercontent.com/u/1187338?v=4)](https://github.com/djlambert "djlambert (167 commits)")[![tvogt](https://avatars.githubusercontent.com/u/2864852?v=4)](https://github.com/tvogt "tvogt (10 commits)")[![AlmogBaku](https://avatars.githubusercontent.com/u/98982?v=4)](https://github.com/AlmogBaku "AlmogBaku (3 commits)")[![mythril](https://avatars.githubusercontent.com/u/169342?v=4)](https://github.com/mythril "mythril (3 commits)")[![mgiustiniani](https://avatars.githubusercontent.com/u/1478947?v=4)](https://github.com/mgiustiniani "mgiustiniani (1 commits)")[![Dazag](https://avatars.githubusercontent.com/u/1424832?v=4)](https://github.com/Dazag "Dazag (1 commits)")[![PowerKiKi](https://avatars.githubusercontent.com/u/72603?v=4)](https://github.com/PowerKiKi "PowerKiKi (1 commits)")[![fogs](https://avatars.githubusercontent.com/u/2734563?v=4)](https://github.com/fogs "fogs (1 commits)")

### Embed Badge

![Health badge](/badges/mythril-doctrine2-spatial/health.svg)

```
[![Health](https://phpackages.com/badges/mythril-doctrine2-spatial/health.svg)](https://phpackages.com/packages/mythril-doctrine2-spatial)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
