I am trying to prepare Symfony 3.4.32 + PostgreSQL + PostGIS environment. I installed jsor/doctrine-postgis, but the error following happens.
Unknown database type geometry requested, Doctrine\DBAL\Platforms\PostgreSQL100Platform may not support it.
I am using EC-CUBE 4.0.3 which is open source software using Symfony 3.4.32 .
I prepared mdillon/postgis docker container. I enable postgis extension and I can use PostGIS.
I installed jsor/doctrine-postgis by composer and set up config files.
services:
# (ommitted)
Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber:
tags:
- { name: doctrine.event_subscriber, connection: default }
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''
env(DATABASE_SERVER_VERSION): ~
doctrine:
dbal:
driver: 'pdo_pgsql'
server_version: "%env(DATABASE_SERVER_VERSION)%"
charset: utf8
# for mysql only
default_table_options:
collate: 'utf8_general_ci'
# With Symfony 3.3, remove the `resolve:` prefix
url: '%env(DATABASE_URL)%'
# types
types:
datetime: 'Eccube\Doctrine\DBAL\Types\UTCDateTimeType'
datetimetz: 'Eccube\Doctrine\DBAL\Types\UTCDateTimeTzType'
geography:
class: 'Jsor\Doctrine\PostGIS\Types\GeographyType'
commented: false
geometry:
class: 'Jsor\Doctrine\PostGIS\Types\GeometryType'
commented: false
raster:
class: 'Jsor\Doctrine\PostGIS\Types\RasterType'
commented: false
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
dql:
string_functions:
NORMALIZE: Eccube\Doctrine\ORM\Query\Normalize
numeric_functions:
EXTRACT: Eccube\Doctrine\ORM\Query\Extract
filters:
option_nostock_hidden:
class: Eccube\Doctrine\Filter\NoStockHiddenFilter
enabled: false
incomplete_order_status_hidden:
class: Eccube\Doctrine\Filter\OrderStatusFilter
enabled: false
<?php
namespace Customize\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* GeoLocation
*
* @ORM\Table(name="dtb_geolocation")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="Customize\Repository\GeoLocationRepository")
*/
class GeoLocation extends \Eccube\Entity\AbstractEntity
{
/**
* @ORM\Column(name="gid", type="integer", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
public $gid;
// (ommitted)
/**
* @ORM\Column(name="geom", type="geometry", options={"geometry_type"="MULTIPOLYGON", "srid"=4612}, nullable=true)
*/
public $geom;
}
Run
bin/console eccube:generate:proxies
bin/console doctrine:schema:update --dump-sql --force
db=# \d dtb_geolocation ;
Table "public.dtb_geolocation "
Column | Type | Collation | Nullable | Default
--------------------+-----------------------------+-----------+----------+-----------------------------------------------------------
gid | integer | | not null | nextval('dtb_geolocation_pkey'::regclass)
// ommitted
geom | geometry(MultiPolygon,4612) | | | NULL::geometry
discriminator_type | character varying(255) | | not null |
Indexes:
"dtb_geolocation_pkey" PRIMARY KEY, btree (gid)
But when I accessed on brower, the error happens.
Unknown database type geometry requested, Doctrine\DBAL\Platforms\PostgreSQL100Platform may not support it.
I clear caches by bin/console cache:clear --no-warmup
, but nothing changes.
Did I make any mistakes?
Aren't geometry type included in Symfony? How can I check it?
Maybe this is an EC-CUBE 4 problem. I guess the doctrine.yaml is loaded after Symfony recognizes database tables.