Я пытаюсь подготовить Symfony 3.4.32 + PostgreSQL + PostGIS. Я установил jsor / doctrine-postgis , но возникает следующая ошибка.
Запрошена геометрия неизвестного типа базы данных, Doctrine \ DBAL \ Platforms \ PostgreSQL100Platform может не поддерживать ее.
Подробности
Я использую EC-CUBE 4.0.3, программное обеспечение с открытым исходным кодом, использующее Symfony 3.4.32.
Я подготовил Контейнер mdillon / postgis . Я включаю расширение postgis и могу использовать PostGIS.
Я установил jsor / doctrine-postgis с помощью composer и настроил файлы конфигурации.
- Я добавил настройки в конец app / config / eccube / services.yaml.
services:
# (ommitted)
Jsor\Doctrine\PostGIS\Event\ORMSchemaEventSubscriber:
tags:
- { name: doctrine.event_subscriber, connection: default }
Я добавляю три типа (география, геометрия, растр) в app / config / eccube / packages / doctrine.yaml.
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
Я подготовил Entity, приложение / Customize / Entity / Geolocation.php.
<?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;
}
Затем я создал таблицу в базе данных PostgreSQL.
Выполнить
bin/console eccube:generate:proxies
bin/console doctrine:schema:update --dump-sql --force
Работает нормально. Таблица «dtb_geolocation» создается и проверяется в PostgreSQL.
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)
Но когда я обращаюсь к браузеру, возникает ошибка.
Запрошена неизвестная геометрия типа базы данных,Doctrine \ DBAL \ Platforms \ PostgreSQL100Платформа может не поддерживать его.
Я очищаю кеши bin/console cache:clear --no-warmup
, но ничего не меняется.
Я допустил какие-либо ошибки?
Aren 'Тип геометрии включен в Symfony? Как я могу это проверить?