Beispiel #1
0
 protected function __construct()
 {
     self::register_autoload();
     $connection_parameters = $this->get_connection_parameters();
     $this->config = Setup::createYAMLMetadataConfiguration(array($this->get_entity_path() . '/mapping'), true);
     $this->em = EntityManager::create($connection_parameters, $this->config);
 }
 /**
  * Initializes context.
  *
  * Every scenario gets its own context instance.
  * You can also pass arbitrary arguments to the
  * context constructor through behat.yml.
  */
 public function __construct()
 {
     $paths = [__DIR__ . '/../../config'];
     $databaseConfig = ['driver' => 'pdo_sqlite', 'path' => __DIR__ . '/../../db.sqlite'];
     $config = Setup::createYAMLMetadataConfiguration($paths, true);
     $this->entityManager = EntityManager::create($databaseConfig, $config);
 }
 /**
  * This method is used to add an entity manager to the doctrine service.
  * @param $id string The id you would like to store with the entity manager.
  * @param ulfberht\module\doctrine\config $config The doctrine configuration for
  *        the entity manager.
  * @return void
  */
 public function addEntityManager($id, config $config)
 {
     $development = $config->develop ? true : false;
     $cache = $config->enableCache ? new ArrayCache() : null;
     //setup type of metadata reading
     switch ($config->type) {
         case 'annotation':
             $docConfig = Setup::createAnnotationMetadataConfiguration($config->paths, $development, null, $cache);
             break;
         case 'xml':
             $docConfig = Setup::createXMLMetadataConfiguration($config->paths, $development, null, $cache);
             break;
         case 'yaml':
             $docConfig = Setup::createYAMLMetadataConfiguration($config->paths, $development, null, $cache);
             break;
     }
     //setup caching
     if (!is_null($cache)) {
         $docConfig->setQueryCacheImpl($cache);
         $docConfig->setMetadataCacheImpl($cache);
     }
     //setup database connection
     $dbConnInfo = array('driver' => $config->database->driver, 'host' => $config->database->host, 'dbname' => $config->database->name, 'user' => $config->database->user, 'password' => $config->database->password);
     //store entity manager
     $this->_doctrineEntityMangers[$id] = EntityManager::create($dbConnInfo, $docConfig);
 }
 protected function setUpEntityManager($transformer = null)
 {
     $evm = new EventManager();
     $evm->addEventSubscriber($this->getSubscriber($transformer));
     $configuration = Setup::createYAMLMetadataConfiguration([__DIR__ . '/Fixture']);
     $this->em = $this->getMockSqliteEntityManager($evm, $configuration);
 }
 /**
  * Create an EntityManager
  *
  * @return EntityManger
  */
 public static function createEntityManager()
 {
     $paths = [__DIR__ . '/yaml'];
     $isDevMode = true;
     $connectionConfig = ['driver' => 'pdo_sqlite', 'database' => ':memory:', 'prefix' => ''];
     $config = Setup::createYAMLMetadataConfiguration($paths, $isDevMode);
     return EntityManager::create($connectionConfig, $config);
 }
 /**
  * Connects to the Redis node
  */
 protected function connectMysql()
 {
     $dbParams = array('driver' => 'pdo_mysql', 'user' => 'blockchain', 'password' => 'blockchain', 'dbname' => 'blockchain', 'host' => 'multichain-mysql.docker');
     $isDevMode = true;
     $paths = array("./yml/");
     $config = Setup::createYAMLMetadataConfiguration($paths, $isDevMode);
     $this->em = EntityManager::create($dbParams, $config);
 }
Beispiel #7
0
 public static function getEntityManager()
 {
     if (static::$entityManager !== null) {
         return static::$entityManager;
     }
     $isDevMode = true;
     $config = Setup::createYAMLMetadataConfiguration(array(realpath(__DIR__ . "/../db")), $isDevMode);
     $arrConfig = parse_ini_file(__DIR__ . "/../config/voetbal.ini", true);
     return static::$entityManager = EntityManager::create($arrConfig["database"], $config);
 }
 /**
  * @return EntityManager
  */
 public function getEm()
 {
     // Basic configuration
     $isDev = true;
     $config = ['driver' => 'pdo_mysql', 'host' => 'localhost', 'user' => 'dev', 'password' => 'dev', 'dbname' => 'doctrine_tutorial'];
     // Paths to directories with entity metadata
     $metadata_paths = [__DIR__ . '/../src/Customer/mapping', __DIR__ . '/../src/Menu/mapping', __DIR__ . '/../src/Product/mapping'];
     $configuration = Setup::createYAMLMetadataConfiguration($metadata_paths, isset($isDev) ? $isDev : false);
     return EntityManager::create($config, $configuration);
 }
 public function __construct()
 {
     require APPPATH . 'config/database.php';
     $dbParams = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database'], 'charset' => $db['default']['char_set'], 'driverOptions' => array('charset' => $db['default']['char_set']));
     $isDevMode = true;
     $config = new Configuration();
     $setup = new Setup();
     $config = $setup->createAnnotationMetadataConfiguration(array(APPPATH . "models"), $isDevMode);
     $config = $setup->createYAMLMetadataConfiguration(array(APPPATH . "models/Yaml"), $isDevMode);
     $this->em = EntityManager::create($dbParams, $config);
 }
 /**
  * Use the register method to register items with the container via the
  * protected $this->container property or the `getContainer` method
  * from the ContainerAwareTrait.
  *
  * @return void
  */
 public function register()
 {
     $config = Setup::createYAMLMetadataConfiguration(array(__DIR__ . "/../../../config/orm/"), $this->container->get('isDevMode'));
     $conn = array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/../../../db.sqlite');
     $this->entityManager = EntityManager::create($conn, $config);
     if (!Type::hasType("task_description")) {
         Type::addType('task_description', TaskDescription::class);
         $this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('description', 'task_description');
     }
     $this->getContainer()->add('entityManager', $this->entityManager);
     $this->getContainer()->add('JGimeno\\TaskReporter\\Entity\\WorkingDayRepositoryInterface', DoctrineWorkingDayRepository::class)->withArgument($this->entityManager);
 }
Beispiel #11
0
function GetEntityManager()
{
    $paths = [realpath(__DIR__ . '/yml/')];
    $isDevMode = false;
    // the connection configuration
    $dbParams = ['driver' => 'pdo_sqlite', 'user' => 'root', 'password' => '', 'dbname' => 'foo', 'path' => ':memory:', 'memory' => 'true'];
    // $config instanceof Doctrine\ORM\Configuration
    $config = Setup::createYAMLMetadataConfiguration($paths, $isDevMode);
    $namespaces = [__DIR__ . '/yml/' => 'NilPortugues\\Tests\\Api\\JsonApi\\Integrations\\Doctrine\\Entity'];
    $driver = new SimplifiedYamlDriver($namespaces);
    $config->setMetadataDriverImpl($driver);
    //replace default driver
    return EntityManager::create($dbParams, $config);
}
Beispiel #12
0
 public function __construct()
 {
     $isDev = config('app.dev');
     // Initialize template engine (Twig)
     $loader = new \Twig_Loader_Filesystem(config('view.path'));
     $this->twig = new \Twig_Environment($loader, ['debug' => $isDev, 'auto_reload' => $isDev, 'cache' => config('view.cache')]);
     // Initialize FormFactory with extensions required for app
     $this->formFactory = (new AppFormFactory($this->twig))->build();
     // Get request data
     $this->request = Request::createFromGlobals();
     // Initialize Doctrine EntityManager
     $config = Setup::createYAMLMetadataConfiguration([base_path("config/doctrine")], $isDev);
     $config->setQueryCacheImpl(new ApcCache());
     $config->setResultCacheImpl(new ApcCache());
     $conn = config('database');
     $this->em = EntityManager::create($conn, $config);
 }
Beispiel #13
0
 public function beforeTestMethod($testMethod)
 {
     $this->mockGenerator->shuntParentClassCalls();
     $this->mockGenerator->orphanize('__construct');
     $pdo = new \mock\PDO();
     $this->mockGenerator->orphanize('__construct');
     $db = new \mock\Doctrine\DBAL\Connection();
     $db->getMockController()->connect = function () {
     };
     $db->getMockController()->getEventManager = function () {
         return new EventManager();
     };
     $db->getMockController()->getDatabasePlatform = function () {
         return new MySqlPlatform();
     };
     $this->mockGenerator->unshuntParentClassCalls();
     $config = Setup::createYAMLMetadataConfiguration([TEST_DATA_DIR . '/doctrine-orm'], true);
     $this->connection = EntityManager::create($db, $config);
 }
 public function register(Application $app)
 {
     $config = json_decode(file_get_contents(__DIR__ . '/../../config/parameters.json'), true);
     $conn = $config["orm.doctrine.db"];
     $paths = $config["orm.doctrine.yml.paths"];
     $debug = $config["debug"];
     $app['debug'] = $debug;
     $app['entity.manager'] = $app->share(function () use($conn, $paths, $debug) {
         $config = Setup::createYAMLMetadataConfiguration($paths, $debug);
         $config->addCustomNumericFunction('RANDOM', Random::class);
         return EntityManager::create($conn, $config);
     });
     $app['word.selector'] = $app->share(function () use($app) {
         $repository = $app['entity.manager']->getRepository(DoctrineWord::class);
         return new StoredWordSelector($repository);
     });
     $app['word.controller'] = $app->share(function () use($app) {
         return new WordController($app['word.selector']);
     });
 }
Beispiel #15
0
 public function __construct()
 {
     require_once __DIR__ . '/Doctrine/ORM/Tools/Setup.php';
     Setup::registerAutoloadDirectory(__DIR__);
     // Load the database configuration from CodeIgniter
     require APPPATH . 'config/database.php';
     $connection_options = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database'], 'charset' => $db['default']['char_set'], 'driverOptions' => array('charset' => $db['default']['char_set']));
     // With this configuration, your model files need to be in application/models/Entity
     // e.g. Creating a new Entity\User loads the class from application/models/Entity/User.php
     $models_namespace = 'Entity';
     $models_path = APPPATH . 'models';
     $proxies_dir = APPPATH . 'models/Proxies';
     $metadata_paths = array(APPPATH . 'models');
     // Set $dev_mode to TRUE to disable caching while you develop
     $dev_mode = true;
     // If you want to use a different metadata driver, change createAnnotationMetadataConfiguration
     // to createXMLMetadataConfiguration or createYAMLMetadataConfiguration.
     $config = Setup::createYAMLMetadataConfiguration($metadata_paths, $dev_mode, $proxies_dir);
     $this->em = EntityManager::create($connection_options, $config);
     $loader = new ClassLoader($models_namespace, $models_path);
     $loader->register();
 }
 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  */
 public function register(Application $app)
 {
     $app['orm.default_options'] = array('params' => array('charset' => null, 'driver' => 'pdo_mysql', 'dbname' => null, 'host' => 'localhost', 'user' => 'root', 'password' => null, 'port' => null), 'dev_mode' => false, 'etities_type' => 'annotations', 'path_entities' => array(__DIR__ . '/../../Application/Entity'), 'proxy_dir' => null);
     $app['orm.options.initializer'] = $app->protect(function () use($app) {
         static $initialized = false;
         if ($initialized) {
             return;
         }
         $initialized = true;
         $tmp = array();
         foreach ($app['orm.default_options'] as $name => $option) {
             $tmp[$name] = isset($app[$name]) ? $app[$name] : $option;
         }
         $app['orm.options'] = $tmp;
     });
     // ORM
     $app['orm.em'] = $app->share(function ($app) {
         $app['orm.options.initializer']();
         $options = $app['orm.options'];
         if (empty($options['path_entities']) || !is_array($options['path_entities'])) {
             throw new \Exception('Option path_entities should be an array of path files entities.');
         }
         if ($options['etities_type'] == 'annotations') {
             $config = Setup::createAnnotationMetadataConfiguration($options['path_entities'], $options['dev_mode'], $options['proxy_dir']);
         } elseif ($options['etities_type'] == 'yaml' || $options['etities_type'] == 'yml') {
             $config = Setup::createYAMLMetadataConfiguration($options['path_entities'], $options['dev_mode'], $options['proxy_dir']);
         } elseif ($options['etities_type'] == 'xml') {
             $config = Setup::createXMLMetadataConfiguration($options['path_entities'], $options['dev_mode'], $options['proxy_dir']);
         }
         if (isset($app['db'])) {
             $entityManager = EntityManager::create($app['db'], $config);
         } else {
             $entityManager = EntityManager::create($options['params'], $config);
             $app['db'] = $entityManager->getConnection();
         }
         return $entityManager;
     });
 }
 /**
  * @return Configuration
  * @throws \LogicException
  */
 protected static function getConfig()
 {
     if (!self::$config) {
         if (!self::$fixtureTypes[self::$fixture]) {
             throw new LogicException('Unknown fixture type for fixture: ' . self::$fixture);
         }
         $type = self::$fixtureTypes[self::$fixture];
         $cache = self::getCache();
         $devMode = true;
         $proxyDir = 'build/tmp/proxies';
         switch ($type) {
             case 'annotation':
                 self::$config = Setup::createAnnotationMetadataConfiguration([self::getEntityDirectory()], $devMode, $proxyDir, $cache, false);
                 break;
             case 'yaml':
                 self::$config = Setup::createYAMLMetadataConfiguration([self::getFixtureDirectory()], $devMode, $proxyDir, $cache);
                 break;
             default:
                 throw new LogicException('Invalid fixture type for fixture');
         }
     }
     return self::$config;
 }
Beispiel #18
0
 public function __invoke()
 {
     $configuration = $this->configuration->toDiArray();
     $configuration[EntityManager::class] = \DI\factory(function () {
         $isDevMode = \DI\link('doctrine.debug');
         $metadataConfiguration = \DI\link('doctrine.metadata.configuration');
         $paths = $metadataConfiguration['paths'];
         switch ($metadataConfiguration['type']) {
             case 'xml':
                 $metadata = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
                 break;
             case 'yml':
                 $metadata = Setup::createYAMLMetadataConfiguration($paths, $isDevMode);
                 break;
             case 'annotations':
                 $metadata = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
                 break;
             default:
                 throw new \InvalidArgumentException('Doctrine can only load its configuration using "xml", "yml" or "annotations" but "' . $metadataConfiguration['type'] . '" was provided as a means.');
         }
         return EntityManager::create(\DI\link('doctrine.connection'), $metadata);
     });
     return $configuration;
 }
 /**
  * Register the properties of the Doctrine ORM Provider
  * 
  * @access public
  * @param MVC $mvc
  * @return void
  */
 public function register(MVC $mvc)
 {
     $default_options = array('params' => array('charset' => null, 'driver' => 'pdo_mysql', 'dbname' => null, 'host' => 'localhost', 'user' => 'root', 'password' => null, 'port' => null), 'dev_mode' => false, 'etities_type' => 'annotations', 'path_entities' => array(), 'proxy_dir' => null);
     $options = array_merge($default_options, $this->options);
     if (empty($options['path_entities']) || !is_array($options['path_entities'])) {
         throw new \Exception('Option path_entities should be an array of path files entities.');
     }
     if ($options['etities_type'] == 'annotations') {
         $config = Setup::createAnnotationMetadataConfiguration($options['path_entities'], $options['dev_mode'], $options['proxy_dir']);
     } elseif ($options['etities_type'] == 'yaml' || $options['etities_type'] == 'yml') {
         $config = Setup::createYAMLMetadataConfiguration($options['path_entities'], $options['dev_mode'], $options['proxy_dir']);
     } elseif ($options['etities_type'] == 'xml') {
         $config = Setup::createXMLMetadataConfiguration($options['path_entities'], $options['dev_mode'], $options['proxy_dir']);
     }
     if ($mvc->hasCvpp('dbal')) {
         $entityManager = EntityManager::create($mvc->getCvpp('dbal'), $config);
     } else {
         $entityManager = EntityManager::create($options['params'], $config);
     }
     if (!$mvc->hasCvpp('dbal')) {
         $mvc->setCvpp('dbal', $entityManager->getConnection());
     }
     $mvc->setCvpp('em', $entityManager);
 }
Beispiel #20
0
 /**
  * @return \Doctrine\ORM\Configuration|mixed
  */
 public function resolve()
 {
     return Setup::createYAMLMetadataConfiguration(array_get($this->settings, 'paths'), array_get($this->settings, 'dev'), array_get($this->settings, 'proxy_path'), $this->getCache());
 }
 /**
  * Create Doctrine configuration.
  *
  * @param array $options
  *
  * @return \Doctrine\ORM\Configuration|null
  */
 protected static function createConfiguration(array $options)
 {
     if ($options['annotation_paths']) {
         return Setup::createAnnotationMetadataConfiguration(static::normalizePaths($options['annotation_paths']), false, $options['proxy_path'], $options['cache_driver'], false);
     }
     if ($options['xml_paths']) {
         return Setup::createXMLMetadataConfiguration(static::normalizePaths($options['xml_paths']), false, $options['proxy_path'], $options['cache_driver']);
     }
     if ($options['yaml_paths']) {
         return Setup::createYAMLMetadataConfiguration(static::normalizePaths($options['yaml_paths']), false, $options['proxy_path'], $options['cache_driver']);
     }
     return null;
 }
 /**
  * @return EntityManager
  */
 public function build()
 {
     \Doctrine\DBAL\Types\Type::addType('UserId', 'Lw\\Infrastructure\\Domain\\Model\\User\\DoctrineUserId');
     \Doctrine\DBAL\Types\Type::addType('WishId', 'Lw\\Infrastructure\\Domain\\Model\\Wish\\DoctrineWishId');
     return EntityManager::create(array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/../../../../../db.sqlite'), Setup::createYAMLMetadataConfiguration([__DIR__ . '/config'], true));
 }
Beispiel #23
0
 public function testYAMLConfiguration()
 {
     $config = Setup::createYAMLMetadataConfiguration(array(), true);
     $this->assertInstanceOf('Doctrine\\ORM\\Configuration', $config);
     $this->assertInstanceOf('Doctrine\\ORM\\Mapping\\Driver\\YamlDriver', $config->getMetadataDriverImpl());
 }
 /**
  * Creates the metadata configuration instance.
  *
  * @param string $type
  * @param array  $paths
  * @param bool   $isDevMode
  * @param string $proxyDir
  * @param Cache  $cache
  * @param bool   $useSimpleAnnotationReader
  *
  * @return Configuration
  * @throws \Exception
  */
 protected function createMetadataConfiguration($type, $paths, $isDevMode, $proxyDir, $cache, $useSimpleAnnotationReader = true)
 {
     switch ($type) {
         case self::METADATA_ANNOTATIONS:
             return Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, $proxyDir, $cache, $useSimpleAnnotationReader);
         case self::METADATA_XML:
             return Setup::createXMLMetadataConfiguration($paths, $isDevMode, $proxyDir, $cache);
         case self::METADATA_YAML:
             return Setup::createYAMLMetadataConfiguration($paths, $isDevMode, $proxyDir, $cache);
         default:
             throw new Exception("Metadata type '{$type}' is not supported.");
     }
 }
Beispiel #25
0
<?php

error_reporting(E_ALL | E_STRICT);
require_once __DIR__ . '/../vendor/autoload.php';
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Setup;
use Silex\Provider\DoctrineServiceProvider;
use Infrastructure\Doctrine\Repositories\RegistryRepository;
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new DoctrineServiceProvider(), ['db.options' => ['driver' => 'pdo_mysql', 'charset' => 'utf8', 'host' => 'localhost', 'user' => 'root', 'password' => 'root', 'dbname' => 'mistrz']]);
$app->register(new \Dflydev\Provider\DoctrineOrm\DoctrineOrmServiceProvider(), ['orm.em.options' => ['mappings' => [['type' => 'yml', 'namespace' => 'Madkom\\RegistryApplication\\Domain', 'path' => [__DIR__ . '/../src/Infrastructure/Doctrine/Mappings']]]]]);
$config = Setup::createYAMLMetadataConfiguration($app['orm.em.options']['mappings'][0]['path'], $app['debug']);
$app['orm.em'] = EntityManager::create($app['db.options'], $config);
$app['repositories.car'] = new RegistryRepository($app['orm.em']);
Beispiel #26
0
<?php

require 'vendor/autoload.php';
date_default_timezone_set('africa/maputo');
use Symfony\Component\Yaml\Yaml;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Configuration;
use JsonSchema\Uri\UriRetriever;
use JsonSchema\Validator;
use Slim\Slim;
$dev = true;
$db = null;
if (getenv('HEROKU')) {
    $db = Yaml::parse(__DIR__ . '/config/db.yaml.heroku');
} else {
    $db = Yaml::parse(__DIR__ . '/config/db.yaml');
}
$dbParams = array('driver' => $db['adapter'], 'user' => $db['user'], 'password' => $db['password'], 'dbname' => $db['database'], 'port' => $db['port'], 'host' => $db['host']);
$pdo = new PDO($db['pdo_adapter'] . ':host=' . $db['host'] . ';dbname=' . $db['database'] . ';port=' . $db['port'], $db['user'], $db['password']);
$dbConfig = Setup::createYAMLMetadataConfiguration(array(__DIR__ . "/app/config/yaml"), $dev);
$entityManager = EntityManager::create($dbParams, $dbConfig);
$em = $entityManager;
$app = new Slim(array('debug' => $dev));
$retriever = new UriRetriever();
$schemaDir = __DIR__ . '/app/schemas/';
#$s = $retriever->retriever($schemaDir = __DIR__ . '/app/schemas/');
$schemaValidator = new Validator();
Beispiel #27
0
<?php

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
require __DIR__ . '/vendor/autoload.php';
global $cfg;
$cfg = json_decode(file_get_contents(__DIR__ . '/config.json'));
$isDevMode = TRUE;
$dbParams = array('driver' => 'pdo_mysql', 'user' => $cfg->database->user, 'password' => $cfg->database->pass, 'dbname' => $cfg->database->db);
$config = Setup::createYAMLMetadataConfiguration(array(__DIR__ . "/src/Entity"), $isDevMode);
$em = EntityManager::create($dbParams, $config);
function slugify($string)
{
    $result = strtolower($string);
    $result = preg_replace("/[^a-z0-9\\s-]/", "", $result);
    $result = trim(preg_replace("/[\\s-]+/", " ", $result));
    $result = preg_replace("/\\s/", "-", $result);
    return $result;
}
function get_countries()
{
    global $em;
    $q = $em->createQuery('SELECT c FROM Country c ORDER by c.name');
    return $q->getResult();
}
function get_country_by_code3l($code3l)
{
    global $em;
    $q = $em->createQuery('SELECT c FROM Country c WHERE c.code3l = ?1');
    $q->setParameter(1, $code3l);
    return $q->getOneOrNullResult();
Beispiel #28
0
<?php

use Doctrine\ORM\Tools\Setup;
require_once "vendor/autoload.php";
// Create a simple "default" Doctrine ORM configuration for XML Mapping
$isDevMode = true;
//$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/src"), $isDevMode);
// stackoverflow.com/questions/1743225/doctrine2-no-metadata-classes-to-process
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . "/module/Application/src/Application/Entity"), $isDevMode, null, null, false);
// or if you prefer yaml or annotations
$config = Setup::createXMLMetadataConfiguration(array(__DIR__ . "/config/xml"), $isDevMode);
$config = Setup::createYAMLMetadataConfiguration(array(__DIR__ . "/config/yaml"), $isDevMode);
// database configuration parameters
$conn = array('driver' => 'pdo_mysql', 'host' => '127.0.0.1', 'dbname' => 'nhpress', 'user' => 'root', 'password' => 'ptH3984z');
// obtaining the entity manager
$entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);
<?php

// replace with file to your own project bootstrap
require_once "vendor/autoload.php";
use Doctrine\ORM\Tools\Console\ConsoleRunner;
$dbParams = array('driver' => 'pdo_mysql', 'user' => 'blockchain', 'password' => 'blockchain', 'dbname' => 'blockchain', 'host' => 'multichain-mysql.docker');
$isDevMode = true;
$paths = array("./yml");
$config = \Doctrine\ORM\Tools\Setup::createYAMLMetadataConfiguration($paths, $isDevMode);
$entityManager = \Doctrine\ORM\EntityManager::create($dbParams, $config);
return ConsoleRunner::createHelperSet($entityManager);
Beispiel #30
0
 $mappingType = strtolower(Arr::get($config, 'doctrine.mapping.type', 'xml'));
 $paths = Arr::get($config, 'doctrine.mapping.paths', []);
 $mappingPaths = [];
 foreach ($paths as $path) {
     $mappingPaths[] = realpath($path);
 }
 switch ($mappingType) {
     case 'xml':
         $xmlConfig = Setup::createXMLMetadataConfiguration($mappingPaths, $env == 'dev');
         $entityManager = EntityManager::create($dbParams, $xmlConfig);
         break;
     case 'yml':
     case 'yaml':
         //$driver = new YamlDriver( $mappingPaths );
         //$driver->setFileExtension('.yml');
         $ymlConfig = Setup::createYAMLMetadataConfiguration($mappingPaths, $env == 'dev');
         //$ymlConfig->setMetadataDriverImpl( $driver );
         $entityManager = EntityManager::create($dbParams, $ymlConfig);
         break;
     case 'annotation':
         $annotationConfig = Setup::createAnnotationMetadataConfiguration($mappingPaths, $env == 'dev');
         $entityManager = EntityManager::create($dbParams, $annotationConfig);
         break;
     default:
         throw new \Exception("Config: Unknown mapping type of '{$mappingType}'.");
 }
 if (empty($entityManager)) {
     throw new \Exception("Config: Unable to instantiate an entity manager. Please check the configuration.");
 }
 $helperSet = new HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($entityManager->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($entityManager)));
 $app = new DoctrineConsole();