我使用 MAMP 服务器和 PHP 7.1.5;Symfony Framework 3.4.2,PostgreSQL 10 用于新项目。我还使用 PostGIS 在 PostgreSQL 中存储几何数据类型的空间数据。因此我安装并使用了:“jsor/doctrine-postgis”:“^1.5”
以下是我的 composer.json 的一部分:
"require": {
"php": ">=5.5.9",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"jsor/doctrine-postgis": "^1.5",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0"
参数.yml:
server_ver: 10.0
database_driver: pdo_pgsql
database_host: localhost
database_port: 5432
database_name: qtqg
database_path: ~
database_user: postgres
database_password: admin
config.yml:
doctrine:
dbal:
default_connection: default
connections:
default:
mapping_types:
_text: string
server_version: %server_ver%
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
path: %database_path%
user: %database_user%
password: %database_password%
persistent: true
charset: UTF8
logging: %kernel.debug%
profiling: %kernel.debug%
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite'
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: '%database_path%'
types:
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
一切正常,我可以使用 cmd 生成实体:
php bin/console doctrine:mapping:import --force AppBundle annotation
之后生成 CRUD:
php bin/console generate:doctrine:crud AppBundleMonitoringAdminBundle:coquan -n --format=annotation --with-write
正在运行的 PHP 是 PHP 7.1.5,我还检查了 C:\Windows 中的 php.ini 文件,并在 MAMP 服务器中加载了 php.ini。php -m
命令显示:
PDO
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
我认为数据驱动程序没有任何问题,因为它可以连接并生成实体,CRUD....但是在生成 CRUD 并尝试访问控制器以列出一个实体中的所有项目后,我得到了错误:
An exception occurred in driver: could not find driver
错误行之一是:
AbstractPostgreSQLDriver->convertException('An exception occurred in driver: could not find driver', object(PDOException)) in vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php (line 176)
我尝试了很多方法,包括将 mamp 更改为 xamp、wamp 服务器、有关如何配置 dbal 的所有建议……但错误仍然存在
谁能帮帮我!