Skip to content

Instantly share code, notes, and snippets.

@kaiohken1982
Created November 22, 2013 18:29
Show Gist options
  • Save kaiohken1982/7604652 to your computer and use it in GitHub Desktop.
Save kaiohken1982/7604652 to your computer and use it in GitHub Desktop.
bootstrap.php (cli-config)
<?php
// bootstrap.php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
require_once "vendor/autoload.php";
// var_dump(__DIR__); exit;
// Create a simple "default" Doctrine ORM configuration for Annotations
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration(
array(__DIR__ . "/path/to/my/Entity"),
$isDevMode,
__DIR__ . '/data/DoctrineORMModule/Proxy'
);
// 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(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'dbuser',
'password' => 'dbpass',
'dbname' => 'dbname',
'charset' => 'utf8',
'driverOptions' => array(
1002 => 'SET NAMES utf8'
),
)
);
// obtaining the entity manager
$entityManager = EntityManager::create($conn, $config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment