longitude-one/doctrine-spatial

Doctrine multi-platform support for spatial types and functions, compliant with Doctrine 2.19, 3.1, and dev ones (3.2 and 4.0).

Maintainers

Package info

github.com/longitude-one/doctrine-spatial

pkg:composer/longitude-one/doctrine-spatial

Transparency log

Statistics

Installs: 1 706 495

Dependents: 1

Suggesters: 0

Stars: 91

Open Issues: 17

5.0.4 2025-07-17 11:32 UTC

README

Doctrine Spatial is a Doctrine extension that implements spatial types and functions.

For example, this extension can help you determine whether your favorite superhero is currently inside Gotham City.

Currently, MySQL and PostgreSQL (with PostGIS) are supported. Support for other platforms could be added if there is enough interest.

Current status

longitude-one/doctrine--spatial Stable release Minimum PHP Version Packagist License

Last integration test Maintainability Downloads Test Coverage Documentation Status

Documentation

The documentation explains how to:

  • install this Doctrine extension,
  • configure the extension,
  • create spatial entities,
  • use spatial functions in your repositories,
  • contribute to the project (and run the tests).

It also includes a glossary covering all available types and spatial functions.

Project origins

This library was originally created by Derek J. Lambert. Alexandre Tranchant forked it from creof/doctrine-spatial, as the original project appeared to be inactive since 2017.

The longitude-one/doctrine-spatial repository follows a well-structured branching strategy:

  • main — Stable 5.0 releases: bug fixes and security updates (no breaking changes).
  • 5.1.x-dev — Controlled deprecations to ease the transition from 5.1 to 6.0 (no breaking changes).
  • 6.0.x-dev — Major new features (may include breaking changes).

This approach ensures clarity, stability, and maintainability for the project.

Compatibility

Version 5.0.x: Version 5.0.x is the current stable version. It has entered maintenance mode and will only receive security patches going forward.

Version 5.1.x: Development efforts are now focused on version 5.1.x, which introduces new factories alongside deprecation notices for constructors. Version 5.1 will require PHP 8.2 or above.

Version 5.2.x: Version 5.2 will require PHP 8.3 or above.

Version 6.x: Starting with version 6.x, compatibility will require PHP 8.5 or above. Support for Doctrine 2.9 and MySQL 5.7 will be dropped.

PHP and Doctrine ORM

This Doctrine extension is compatible with PHP 8.1+ and Doctrine ORM ^2.9, ^3.1, and aims to remain compatible with the upcoming major version ^4.x-dev. Security fixes follow the PHP support roadmap.

Databases compatibility

doctrine-spatial MySQL. MariaDB PostgreSQL PostGIS SQL Server Statut
5.0 5.7, 8.0 10.6 18. 3.6 Stable (security fixes).
5.1 8.4 10.11 18 3.6 2017 Next version (development)
6.0 8.4 10.11 18 3.6 2017 in development.

Known limitation: longitude-one/doctrine-spatial cannot store the SRID on MySQL, nor SQL Server. Internally, the extension uses Well-Known Text (WKT) to convert internal types to database types. Since doctrine/orm does not support a custom persister or collection persister, we cannot pass both parameters (WKT and SRID) at once. Extended Well-Known Text (EWKT) solves this, but it is only supported by PostGIS. A possible solution under investigation is to build an external Well-Known Binary (WKB) converter, usable from the convertToDatabaseValue methods of both doctrine/orm and longitude-one/doctrine-spatial.