ines pelaez
ines pelaez

Reputation: 523

Error connecting and creating to database

I am following the tutorial for Doctrine: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/getting-started.html

I changed the bootstrap file to include my database to:

<?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);

But get this message when I try to run:

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    

Thank you in advance

Upvotes: 0

Views: 383

Answers (1)

Panther
Panther

Reputation: 9408

Host is supposed to be an ip address or a host name. You have included http in it which is a protocol. I suppose your host should be only 192.******* instead of http://192.*******.

Upvotes: 3

Related Questions