Doctrine extension to persist spatial data objects.

Overview

doctrine-Spatial

Doctrine-spatial is a doctrine extension. It implements spatial types and functions. As exemple, this extension can help you to know if your favorite superheroes is inside Gotham city.

Currently, MySQL and PostgreSQL with PostGIS are supported. Could potentially add support for other platforms if an interest is expressed.

Current status

Test on PHP/MySQL Test on PHP/PgSQL Main Status Downloads Documentation Status Coverage Status

Documentation

The new documentation explain how to:

  • install this doctrine extension,
  • configure this extension,
  • create spatial entities,
  • use spatial functions in your repositories,
  • contribute (and test)

The documentation contains a glossary of all available types and all available spatial functions.

Project origins

This useful library was created by Derek J. Lambert. Alexandre Tranchant forked it from creof/doctrine-spatial because project seems to be non-active since 2017.

The dev branch can be used, but be careful backward compatibility aren't warrantied. The main branch will be dedicated to fix issue. The release 3.0 will be published during summer 2021. The release 4.0 will be published during winter 2022 and compatibility with PHP7.4 will be abandoned because of PHP roadmap

Compatibility

PHP

This doctrine extension is compatible with PHP 7.4+ and PHP 8.0 Security fixes will follow the PHP Roadmap.

MySQL 5.7 and 8.0

A lot of functions change their names between these two versions. The MySQL 5.7 deprecated functions are not implemented.

MariaDB 10

This version is NOT compatible with MariaDB version. Some spatial functions seems to work, but their results are different from MySQL version (StContains function is a good example).

PostgreSQL

This spatial library is compatible with PostgreSql13. This library is tested with Postgis 3.1.

Migrating from creof/doctrine2-spatial

Update your composer.json to replace creof/doctrine2-spatial by longitude-one/doctrine-spatial.

Update the namespace, each use CrEOF\Spatial\... by use LongitudeOne\Spatial\...

Help wanted

RFC I don't have enough money to buy the last edition of the ISO/IEC 13249-3:2016. I only bought the previous version. This document is essential to know which functions are in Standard and which one are specific to a database engine. If anyone has bought one and don't use it anymore, feel free to forward it. You can contact me by mail, specified in composer.json.

Microsoft SQL Server I'm searching help to create a docker delivering a Microsoft SQL Server service. So I'll be able to implement compatibility with this database server.

MariaDB I'm searching help to create a Github action delivering a MariaDB service, to launch test and determine if this library is compatible.

Comments
  • Remove deprecation notice

    Remove deprecation notice

    Doctrine\ORM\Query\AST\Functions\FunctionNode::parse() has a @return void annotation, which might become a native return type declaration in the future.

    Symfony's DebugClassLoader checks for inconsistencies between return types in classes and their parents/interfaces, and triggers a deprecation notice every time the library is used in a Symfony dev environment. This @return annotation fixes that.

    bug on test only 
    opened by cinamo 3
  • Latitude / Longitude issue

    Latitude / Longitude issue

    I think I found a very confusing bug which is easy to replicate:

    Test script

    $lat = 52.092876;
    $lon = 5.104480;
    var_dump($lat, $lon);
    $point = new \LongitudeOne\Spatial\PHP\Types\Geometry\Point($lat, $lon);
    var_dump($point->getLatitude(), $point->getLongitude());
    

    Outputs

    float(52.092876)
    float(5.10448)
    float(5.10448)
    float(52.092876)
    

    https://github.com/longitude-one/doctrine-spatial/blob/main/lib/LongitudeOne/Spatial/PHP/Types/AbstractPoint.php#L202 Refers as Lat Lon construct (in this order) and writes lat to X and lon to Y

    This is the issue: When using getLatitude() it will return the data from Y instead of X. https://github.com/longitude-one/doctrine-spatial/blob/main/lib/LongitudeOne/Spatial/PHP/Types/AbstractPoint.php#L65

    Would changing the getLatitude and getLongitude fix it entirely or is there unintended side effects for this?

    bug 
    opened by Vincentv92 2
  • Doctrine deprecated methods and classes should be replaced

    Doctrine deprecated methods and classes should be replaced

    Because of doctrine updates, there are still some deprecated functions.

    OrmMockTestCase.php:

    • setMethods *2
    • setMetaDataCacheImpl (fixed by #6)

    OrmTestCase.php:

    • executeUpdate
    • exec
    • setMetaDataCacheImpl (fixed by #6)

    WrappingTest.php:

    • class Doctrine\DBAL\Version is deprecated
    opened by Alexandre-T 1
  • Class 'Doctrine\Common\Cache\ArrayCache' not found

    Class 'Doctrine\Common\Cache\ArrayCache' not found

    An error appears when starting test jobs after the PR #4 was submitted.

    This error isn't due to the PR.

    1. LongitudeOne\Spatial\Tests\DBAL\Types\Geography\GeoPolygonTypeTest::testNullPolygon Error: Class 'Doctrine\Common\Cache\ArrayCache' not found
    opened by Alexandre-T 1
  • Class ORMException deprecated

    Class ORMException deprecated

    Replace all ORMException

    namespace Doctrine\ORM;
    
    /**
     * Base exception class for all ORM exceptions.
     *
     * @deprecated Use Doctrine\ORM\Exception\ORMException for catch and instanceof
     */
    class ORMException extends Exception
    
    opened by Alexandre-T 0
  • Declare the allow-plugins config

    Declare the allow-plugins config

    For additional security you should declare the allow-plugins config with a list of packages names that are allowed to run code. See https://getcomposer.org/allow-plugins You have until July 2022 to add the setting. Composer will then switch the default behavior to disallow all plugins.

    bug on test only 
    opened by Alexandre-T 0
  • Upgrade to phpcs fixer 3

    Upgrade to phpcs fixer 3

    Message : You are running PHP CS Fixer v2, which is not maintained anymore. Please update to v3. You may find an UPGRADE guide at https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/v3.3.0/UPGRADE-v3.md

    bug on test only 
    opened by Alexandre-T 0
  • Test failed because of doctrine update

    Test failed because of doctrine update

    Some tests now failed because of doctrine updates. This is due to :

    • updates on namespaces
    • final classes cannot be mocked
    • some Postgresql functions returns values in another order
    bug on test only 
    opened by Alexandre-T 0
  • Fixtures for functional tests should be internal

    Fixtures for functional tests should be internal

    Fixtures for functional tests should be internal to avoid that PHPStorm or any other code editor purpose these non-useful classes during autocompletion.

    bug 
    opened by Alexandre-T 0
  • Fixing cache

    Fixing cache

    Replacing no-more existing Doctrine\Common\Cache\ArrayCache by Cache\Adapter\PHPArray\ArrayCachePool Replacing deprecated method setMetadataCacheImpl from Doctrine\ORM\Configuration by setMetadataCache

    opened by Alexandre-T 0
  • ST_GeomFromText is missing when using DBAL insert / update methods

    ST_GeomFromText is missing when using DBAL insert / update methods

    Hi there.

    First thing first: thank you for this package.

    Let's talk about the following example:

    CREATE TABLE `table_foobar` (
      `name` varchar(19) NOT NULL,
      `position` point DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
    
    $point = new Point($longitude, $latitude);
    
    $connection->insert(
      'table_foobar',
      [
        'name' => 'john',
        'position' => new Point(2.35222, 48.8566);
      ],
     [
        'position' => new PointType(),
      ]
    );
    

    I get the following exception.

    [Doctrine\DBAL\Exception\DriverException]
      An exception occurred while executing 'INSERT INTO `table_foobar` (name, position) VALUES (?, ?)' with params ["john", "POINT(2.35222 48.8566)"]:
    
      SQLSTATE[22003]: Numeric value out of range: 1416 Cannot get geometry object from data you send to the GEOMETRY field
    

    Do you have any clue to solve this error?

    Note that I'm just using DBAL Doctrine integration.

    Regards.

    opened by armetiz 1
  • SRID POINT Mysql 8+ Not saved

    SRID POINT Mysql 8+ Not saved

    Mysql 8 can save PONT like this: ST_SRID(POINT(...), 4326) But

                $point = new Point($lon, $lat);
                $point->setSrid(4326); # !!!!!!!!!!
                $entity->setPoint($point);
    

    Not working - SRID did not saved

    enhancement help wanted 
    opened by tebaly 1
  • SLQLite issue

    SLQLite issue

    Is there a way to go around the SQLite limitation? I use it only for fast testing and tests don't even need to cover this value.

    The error I get when I try to update schema:

    In AbstractSpatialType.php line 235:
                                                          
    DBAL platform "sqlite" is not currently supported. 
    

    The only idea I have is to make a Doctrine event that would completely remove it when in test environment but that sounds very wrong.

    opened by zmitic 6
  • Add test for missed functions

    Add test for missed functions

    There is no test for the next files:

    • PostGis: SpScale.php
    • PostGis: SpTransform.php
    • PostGis: SpTranslate.php
    • Standard: StConvexHull.php(https://coveralls.io/builds/40810010/source?filename=lib%2FLongitudeOne%2FSpatial%2FORM%2FQuery%2FAST%2FFunctions%2FStandard%2FStConvexHull.php)
    good first issue help wanted 
    opened by Alexandre-T 0
Releases(3.0.2)
  • 3.0.2(Feb 16, 2022)

  • 3.0.1(Jan 20, 2022)

    Version 3.0.1

    • Removing deprecation due to doctrine and class ORMException ;
    • allow-plugins configured in composer.json ;
    • some upgrade for doctrine-spatial contributors (phpcsfixer v3) ;
    • fixing some tests ;
    • Fixtures used by internal functional tests are now internal to avoid confusion with auto-completion plugin ;
    • Minor improvements in documentation.
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-RC4(Jul 20, 2021)

    Test upgraded. Weak code detected by PhpStorm fixed. Documentation up to date. Code coverage improved.

    If no issues are detected, Version 3.0 will be release August 17th.

    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-RC3(Jun 30, 2021)

  • 3.0.0-RC2(Jun 23, 2021)

    • removing deprecated methods PHPUnit::Mock::setMethods
    • removing deprecated method Doctrine::executeUpdate
    • removing deprecated method Doctrine::exec
    • Replacing no-more existing Doctrine\Common\Cache\ArrayCache by Cache\Adapter\PHPArray\ArrayCachePool
    • Replacing deprecated method setMetadataCacheImpl from Doctrine\ORM\Configuration by setMetadataCache
    • Fix package name and namespaces in documentation (thanks @toooni )
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-RC1(Jun 18, 2021)

    As the creof team doesn't have anymore time to maintain their awesome spatial extension for doctrine (creof/doctrine2-spatial), this package replaces it.

    This package starts as the third version, because last release of creof/doctrine2-spatial is 2.0.

    Look at the Changelog, to know each updates, but the essential is:

    • PHP8.0 is now supported (and tested),
    • MySQL and PostgreSQL are still supported,
    • Postgis3.1 is supported.

    This package includes improvements in the PR#209

    Source code(tar.gz)
    Source code(zip)
🔌 A Doctrine DBAL Driver implementation on top of Swoole Coroutine PostgreSQL extension

Swoole Coroutine PostgreSQL Doctrine DBAL Driver A Doctrine\DBAL\Driver implementation on top of Swoole\Coroutine\PostgreSQL. Getting started Install

Leo Cavalcante 19 Nov 25, 2022
Doctrine Object Relational Mapper (ORM)

3.0.x 2.9.x 2.8.x Doctrine 2 is an object-relational mapper (ORM) for PHP 7.1+ that provides transparent persistence for PHP objects. It sits on top o

Doctrine 9.5k Jan 2, 2023
Spot v2.x DataMapper built on top of Doctrine's Database Abstraction Layer

Spot DataMapper ORM v2.0 Spot v2.x is built on the Doctrine DBAL, and targets PHP 5.4+. The aim of Spot is to be a lightweight DataMapper alternative

Spot ORM 602 Dec 27, 2022
:gem: Simple MySQLi Abstraction Layer + Doctrine/DBAL support

?? Simple MySQLi Class This is a simple MySQL Abstraction Layer compatible with PHP 7+ that provides a simple and secure interaction with your databas

Lars Moelleken 40 Sep 5, 2022
Doctrine Database Abstraction Layer

Doctrine DBAL 4.0-dev 3.0 2.13 N/A N/A Powerful database abstraction layer with many features for database schema introspection, schema management and

Doctrine 8.9k Dec 28, 2022
A drop-in Doctrine ORM 2 implementation for Laravel 5+ and Lumen

Laravel Doctrine ORM A drop-in Doctrine ORM 2 implementation for Laravel 5+ $scientist = new Scientist( 'Albert', 'Einstein' ); $scientist->a

Laravel Doctrine 777 Dec 17, 2022
Psalm Stubs for doctrine/mongodb-odm library

doctrine-mongodb-psalm-plugin A Doctrine plugin for Psalm (requires Psalm v4). Installation: $ composer require --dev runtothefather/doctrine-mongodb-

Evgeny 6 Jun 15, 2022
Provides integration for Doctrine with various Symfony components.

Doctrine Bridge The Doctrine bridge provides integration for Doctrine with various Symfony components. Resources Contributing Report issues and send P

Symfony 3k Dec 23, 2022
Doctrine PHP mapping driver

WORK IN PROGRESS! Doctrine PHP mapping driver Alternative mapping driver that allows to write mappings in PHP. Documentation Associations examples TOD

Andrey Klimenko 3 Aug 15, 2021
Monadic Doctrine repositories helper classes and services.

Doctrine Repository Monadic Helper Description This project provides the necessary classes and services to use Doctrine repositories in a more functio

(infinite) loophp 10 Aug 29, 2022
PostgreSQL enhancements for Doctrine

PostgreSQL enhancements for Doctrine. Provides support for advanced data types (json, jssnb, arrays), text search, array operators and jsonb specific functions.

Martin Georgiev 258 Dec 31, 2022
🎩✨🌈 OOP Proxy wrappers utilities - generates and manages proxies of your objects

Proxy Manager This library aims to provide abstraction for generating various kinds of proxy classes. Documentation You can learn about the proxy patt

Marco Pivetta 4.8k Dec 29, 2022
ATK Data - Data Access Framework for high-latency databases (Cloud SQL/NoSQL).

ATK Data - Data Model Abstraction for Agile Toolkit Agile Toolkit is a Low Code framework written in PHP. Agile UI implement server side rendering eng

Agile Toolkit 257 Dec 29, 2022
A simple program to query mysql data and display the queried data in JSON format

A simple program to query mysql data and display the queried data in JSON format. The data displayed in JSON format will change and update as the data in your mysql database changes.

null 2 Mar 7, 2022
Phpstan-dba - database handling related class reflection extension for PHPStan & framework-specific rules

database handling class reflection extension for PHPStan This extension provides following features: PDO->query knows the array shape of the returned

Markus Staab 175 Dec 29, 2022
Php mongodb admin, use new mongodb extension.

EasyMongo EasyMongo is a Mongodb web management application. This project is based on iwind/RockMongo, uses the latest mongodb-extension + mongo-php-l

Meng Wang 8 Oct 31, 2022
A data mapper implementation for your persistence model in PHP.

Atlas.Orm Atlas is a data mapper implementation for persistence models (not domain models). As such, Atlas uses the term "record" to indicate that its

null 427 Dec 30, 2022
MySQL Load Data Infile Support For Laravel

Laravel Load File ?? A package to help with loading files into MySQL tables. This uses MySQL's LOAD DATA statement to load text files quickly into you

Ellis Green 64 Dec 30, 2022
Eloquent Filter is a package for filter data of models by the query strings. Easy to use and fully dynamic.

Eloquent Filter Eloquent Filter adds custom filters to your Eloquent Models in Laravel. It's easy to use and fully dynamic. Table of Content Introduct

Mehdi Fathi 327 Dec 28, 2022