我正在遵循Doctrine教程:http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html
我更改了bootstrap文件以将我的数据库包含在:
<?php
// bootstrap.php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
require_once "vendor/autoload.php";
// Create a simple "default" Doctrine ORM configuration for Annotations
$isDevMode = false;
$paths = array(__DIR__."/src");
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
// or if you prefer yaml or XML
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
//$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
// database configuration parameters
$conn = array(
'host' => 'http://192.*******',
'port' => '3306',
'user' => '********',
'password' => '****',
'dbname' => 'bugs',
'charset' => 'UTF8',
'driver' => 'pdo_mysql',
);
// obtaining the entity manager
$entityManager = EntityManager::create($conn, $config);
但是当我尝试运行时收到此消息:
vendor/bin/doctrine orm:schema-tool:create
[Doctrine\DBAL\Exception\ConnectionException]
An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddr
esses: getaddrinfo failed: Name or service not known
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name o
r service not known
[PDOException]
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name o
r service not known
[PDOException]
PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or s
ervice not known
提前谢谢
答案 0 :(得分:3)
主机应该是IP地址或主机名。您已在其中包含http
这是一个协议。我认为您的主机应该只是192.*******
而不是http://192.*******
。