Exemple #1
0
 /**
  * Creates and returns a new instance of doctrine
  * @return EntityManager The Doctrine Entity Manager
  */
 public function getDoctrineEntityManager()
 {
     try {
         require_once PATH_3RD_PARTY . '/doctrine-orm/vendor/autoload.php';
         $config = Doctrine\ORM\Tools\Setup::createYAMLMetadataConfiguration(array(PATH_INCLUDE . '/models/mapping/yml'), true);
         $config->setProxyDir(PATH_INCLUDE . '/models/Proxies');
         $config->setProxyNamespace('Babesk\\Proxies');
         $config->addEntityNamespace('DM', 'Babesk\\ORM');
         $conn = array('driver' => 'pdo_mysql', 'dbname' => $this->_databaseName, 'user' => $this->_username, 'password' => $this->_password, 'host' => $this->_host);
         $loader = new \Doctrine\Common\ClassLoader('Babesk', PATH_INCLUDE . '/models/Entities');
         $loader->register();
         $loader = new \Doctrine\Common\ClassLoader('Repository', PATH_INCLUDE . '/models');
         $loader->register();
         $entityManager = Doctrine\ORM\EntityManager::create($conn, $config);
         $entityManager->getEventManager()->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci'));
         return $entityManager;
     } catch (Exception $e) {
         throw new Exception('Could not set up doctrine entity manager!');
     }
 }
Exemple #2
0
<?php

require "Doctrine/ORM/Tools/Setup.php";
Doctrine\ORM\Tools\Setup::registerAutoloadDirectory('.');
//  use Doctrine\ORM\Tools\Setup;
//  use Doctrine\ORM\EntityManager;
$isDevMode = true;
// the connection configuration
$dbParams = array('driver' => 'pdo_mysql', 'user' => 'lab', 'password' => '7DULcn6NaWdvVxaN', 'dbname' => 'lab', 'host' => 'localhost');
//$config = Setup::createAnnotationMetadataConfiguration(array('config/Entities/'), $isDevMode);
$config = Doctrine\ORM\Tools\Setup::createYAMLMetadataConfiguration(array('config/yml/'), $isDevMode);
$em = Doctrine\ORM\EntityManager::create($dbParams, $config);
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)));
include "ORM/load.php";
define('VENDOR_PATH', __DIR__ . '/../../vendor/');
define('APP_PATH', __DIR__ . '/../../app/');
define('CONFIG_PATH', __DIR__ . '/../../app/config/');
define('TEMPLATE_PATH', __DIR__ . '/../../web/views/');
define('PUBLIC_PATH', __DIR__ . '/../../public/');
// Password hasing
define("PBKDF2_HASH_ALGORITHM", "sha256");
define("PBKDF2_ITERATIONS", 1000);
define("PBKDF2_SALT_BYTE_SIZE", 24);
define("PBKDF2_HASH_BYTE_SIZE", 24);
define("HASH_SECTIONS", 4);
define("HASH_ALGORITHM_INDEX", 0);
define("HASH_ITERATION_INDEX", 1);
define("HASH_SALT_INDEX", 2);
define("HASH_PBKDF2_INDEX", 3);
// Registrer autoloaders
require VENDOR_PATH . 'autoload.php';
// Load environment variables
try {
    (new Dotenv\Dotenv(ROOT_PATH))->load();
} catch (Exception $e) {
    echo $e;
}
$config = ['path.root' => ROOT_PATH, 'path.public' => PUBLIC_PATH, 'path.app' => APP_PATH];
require CONFIG_PATH . 'slim.php';
require CONFIG_PATH . 'doctrine.php';
$setup = Doctrine\ORM\Tools\Setup::createYAMLMetadataConfiguration([APP_PATH . 'models/schemas'], getenv('APP_DEBUG'));
$em = \Service\Registry::set('em', Doctrine\ORM\EntityManager::create($config['doctrine'], $setup));
$app = \Service\Registry::set('slim', new \Slim\Slim($config['slim']));
require APP_PATH . 'routes.php';
return $app;