1. Go to this page and download the library: Download jsor/doctrine-postgis library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jsor / doctrine-postgis example snippets
use Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber;
$entityManager->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
use Jsor\Doctrine\PostGIS\Event\DBALSchemaEventSubscriber;
$connection->getEventManager()->addEventSubscriber(new DBALSchemaEventSubscriber());
use Doctrine\ORM\Mapping as ORM;
use Jsor\Doctrine\PostGIS\Types\PostGISType;
#[ORM\Entity]
class MyEntity
{
#[ORM\Column(type: PostGISType::GEOMETRY)]
private string $geometry;
#[ORM\Column(type: PostGISType::GEOGRAPHY)]
private string $geography;
}
use Doctrine\ORM\Mapping as ORM;
use Jsor\Doctrine\PostGIS\Types\PostGISType;
#[ORM\Entity]
class MyEntity
{
#[ORM\Column(
type: PostGISType::GEOMETRY,
options: ['geometry_type' => 'POINT'],
)]
public string $point;
#[ORM\Column(
type: PostGISType::GEOMETRY,
options: ['geometry_type' => 'POINTZM'],
)]
public string $point4D;
#[ORM\Column(
type: PostGISType::GEOMETRY,
options: ['geometry_type' => 'POINT', 'srid' => 3785],
)]
public string $pointWithSRID;
public function __construct(
string $point,
string $point4D,
string $pointWithSRID,
) {
$this->point = $point;
$this->point4D = $point4D;
$this->pointWithSRID = $pointWithSRID;
}
}