本文整理汇总了PHP中Doctrine\Common\ClassLoader类的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader类的具体用法?PHP ClassLoader怎么用?PHP ClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ClassLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH . 'config/database.php';
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'libraries');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/"));
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$reader = new AnnotationReader();
$driverImpl = new AnnotationDriver($reader, array(APPPATH . "models/Entities"));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
$config->setAutoGenerateProxyClasses(true);
AnnotationRegistry::registerLoader('class_exists');
// Database connection information
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
示例2: initDoctrine
function initDoctrine()
{
require_once __DIR__ . '/../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
$classLoader = new ClassLoader('Doctrine\\ORM', realpath(__DIR__ . '/../lib'));
$classLoader->register();
$classLoader = new ClassLoader('Doctrine\\DBAL', realpath(__DIR__ . '/../lib/vendor/doctrine-dbal/lib'));
$classLoader->register();
$classLoader = new ClassLoader('Doctrine\\Common', realpath(__DIR__ . '/../lib/vendor/doctrine-common/lib'));
$classLoader->register();
$classLoader = new ClassLoader('Symfony', realpath(__DIR__ . '/../lib/vendor'));
$classLoader->register();
$classLoader = new ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new ClassLoader('Proxies', __DIR__);
$classLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ApcCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/Entities"));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
// Database connection information
$connectionOptions = array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/database.sqlite');
// Create EntityManager
$em = EntityManager::create($connectionOptions, $config);
return $em;
}
示例3: __construct
public function __construct()
{
$this->setRoot("/var/www/html/uan/");
$this->setEntidade(array($this->getRoot() . "models/"));
$this->setIsDevMode(true);
$mode = "DESENVOLVIMENTO";
$config = Setup::createAnnotationMetadataConfiguration($this->getEntidade(), $this->getIsDevMode(), NULL, NULL, FALSE);
if ($mode == "DESENVOLVIMENTO") {
$cache = new \Doctrine\Common\Cache\ArrayCache();
} else {
$cache = new \Doctrine\Common\Cache\ApcCache();
}
$config = new Configuration();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver($this->getRoot() . 'models/');
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setProxyDir($this->getRoot() . 'proxies/');
$config->setProxyNamespace('proxies');
if ($mode == "DESENVOLVIMENTO") {
$config->setAutoGenerateProxyClasses(true);
} else {
$config->setAutoGenerateProxyClasses(false);
}
$config = Setup::createAnnotationMetadataConfiguration($this->getEntidade(), $this->getIsDevMode(), NULL, NULL, FALSE);
$dbParams = array('driver' => 'pdo_mysql', 'user' => 'root', 'password' => '', 'dbname' => 'ceafie', 'charset' => 'utf8', 'driverOptions' => array(1002 => 'SET NAMES utf8'));
$this->em = EntityManager::create($dbParams, $config);
$loader = new ClassLoader('Entity', __DIR__ . '/models');
$loader->register();
}
示例4: __construct
public function __construct()
{
// load database configuration from CodeIgniter
if (!file_exists($file_path = APPPATH . 'config/' . ENVIRONMENT . '/database.php') && !file_exists($file_path = APPPATH . 'config/database.php')) {
throw new Exception('The configuration file database.php does not exist.');
}
require $file_path;
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/"));
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/Proxies');
$proxiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/Entities'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . '/models/Proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
$logger = new EchoSQLLogger();
$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(true);
// Database connection information
$connectionOptions = $this->convertDbConfig($db['default']);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
示例5: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH . 'config/database.php';
//A Doctrine Autoloader is needed to load the models
$entitiesClassLoader = new ClassLoader('Entity', APPPATH . "models");
$entitiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
AnnotationRegistry::registerFile(APPPATH . "vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
$reader = new AnnotationReader();
$driverImpl = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array(APPPATH . 'models/Entity'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . 'models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
// $logger = new EchoSQLLogger;
// $config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => 'root', 'password' => 'whoami', 'host' => 'localhost', 'dbname' => 'pms3');
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
示例6: __construct
public function __construct()
{
//Set up class loading. You cold use different autoloaders, provider by your
//if you want to.
require_once APPPATH . 'third_party/DoctrineORM-2.2.2/libraries/Doctrine/Common/ClassLoader.php';
require_once APPPATH . 'third_party/DoctrineORM-2.2.2/libraries/Doctrine/ORM/Tools/Setup.php';
Doctrine\ORM\Tools\Setup::registerAutoloadDirectory(APPPATH . 'third_party/DoctrineORM-2.2.2/libraries/');
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'third_party/DoctrineORM-2.2.2/libraries');
$doctrineClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
//Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver([APPPATH . 'models/Entities']);
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
//Proxy configuration
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
//Set up logger
//$logger = new EchoSQLLogger;
//$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(true);
include APPPATH . 'config/database.php';
//Database connection information
$connectionOptions = ['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' => [1002 => 'SET NAMES utf8']];
//Enforce connection character set. This is very important if you are
//using MySQL and InnoDB tables!
//Doctrine_Manager::connection()->setCharset('utf8');
//Doctrine_Manager::connection()->setCollate('utf8_general_ci');
//Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
示例7: getDocumentManager
protected function getDocumentManager()
{
if (is_null($this->_documentManager)) {
$options = $this->getOptions();
// ODM Class
$classLoader = new ClassLoader('Doctrine\\ODM\\MongoDB', APPLICATION_PATH . '/../library');
$classLoader->register();
// Common Class
$classLoader = new ClassLoader('Doctrine\\Common', APPLICATION_PATH . '/../library');
$classLoader->register();
// MongoDB Class
$classLoader = new ClassLoader('Doctrine\\MongoDB', APPLICATION_PATH . '/../library');
$classLoader->register();
$classLoader = new ClassLoader('Documents', $options['documentPath']);
$classLoader->register();
$config = new Configuration();
$config->setProxyDir($options['proxyDir']);
$config->setProxyNamespace($options['proxyNamespace']);
$config->setHydratorDir($options['hydratorDir']);
$config->setHydratorNamespace($options['hydratorNamespace']);
$reader = new AnnotationReader();
AnnotationDriver::registerAnnotationClasses();
$config->setMetadataDriverImpl(new AnnotationDriver($reader, $options['documentPath']));
$config->setDefaultDB($options['dbname']);
$this->_documentManager = DocumentManager::create(new Connection($options['server']), $config);
}
return $this->_documentManager;
}
示例8: __construct
public function __construct(array $dbConfig, array $options = array())
{
extract($options);
$entityClassLoader = new ClassLoader("Entities", $entityPath);
$entityClassLoader->register();
$proxyPath = isset($proxyPath) ? $proxyPath : $entityPath;
$proxyClassLoader = new ClassLoader("Proxies", $proxyPath);
$proxyClassLoader->register();
$config = new Configuration();
if ($isDevMode || $isArrayCache) {
$cache = new ArrayCache();
} else {
$cache = new ApcCache();
}
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
$config->setProxyDir($proxyPath);
$config->setProxyNamespace($namespaces["proxy"]);
if (isset($isDevMode) && $isDevMode) {
$config->setAutogenerateProxyClasses(true);
}
if (isset($driverClass) && class_exists($driverClass)) {
$annotationDriver = new $driverClass($entity_driver);
} else {
$annotationDriver = new AnnotationDriver(new AnnotationReader(), array($entityPath));
AnnotationRegistry::registerLoader('class_exists');
}
$config->setMetadataDriverImpl($annotationDriver);
$this->setEntityManager($dbConfig, $config);
}
示例9: __construct
/**
* constructor
*/
public function __construct()
{
// load database configuration from CodeIgniter
require APPPATH . 'config/database.php';
$doctrineClassLoader = new ClassLoader('Doctrine', FCPATH . 'vendors');
$doctrineClassLoader->register();
$symfonyClassLoader = new ClassLoader('Symfony', FCPATH . 'vendors/Doctrine');
$symfonyClassLoader->register();
$entityClassLoader = new ClassLoader('Entity', APPPATH . 'models');
$entityClassLoader->register();
$config = Doctrine\ORM\Tools\Setup::createConfiguration(ENVIRONMENT !== 'production');
$driverImpl = new AnnotationDriver(new AnnotationReader(), [APPPATH . 'models']);
AnnotationRegistry::registerLoader('class_exists');
$config->setMetadataDriverImpl($driverImpl);
// Proxy configuration
$config->setProxyDir(APPPATH . 'models/Proxies');
$config->setProxyNamespace('Proxies');
if (ENVIRONMENT === 'production') {
// Set up caches
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
} else {
// Set up logger
// $logger = new EchoSQLLogger;
// $config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
}
// Database connection information
$connectionOptions = array('driver' => $db[$active_group]['dbdriver'], 'user' => $db[$active_group]['username'], 'password' => $db[$active_group]['password'], 'host' => $db[$active_group]['hostname'], 'port' => $db[$active_group]['port'], 'dbname' => $db[$active_group]['database'], 'charset' => $db[$active_group]['char_set'], 'collation' => $db[$active_group]['dbcollat']);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
示例10: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH . 'config/database.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
//require_once APPPATH.'libraries/Doctrine/Common/ClassLoader.php';
// We use the Composer Autoloader instead - just set
// $config['composer_autoload'] = TRUE; in application/config/config.php
//require_once APPPATH.'vendor/autoload.php';
//A Doctrine Autoloader is needed to load the models
$entitiesClassLoader = new ClassLoader('Entities', APPPATH . "models");
$entitiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/Entities'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
$logger = new EchoSQLLogger();
$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => 'dev_pila', 'password' => 'damienludothomas', 'host' => 'localhost', 'dbname' => 'tradr');
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
示例11: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH . 'config/development/database.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
require_once APPPATH . 'libraries/Doctrine/Common/ClassLoader.php';
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'libraries');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/"));
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
// Set up caches
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/Entities'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Proxy configuration
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
$logger = new EchoSQLLogger();
$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
// Database connection information
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db['default']['username'], 'password' => $db['default']['password'], 'host' => $db['default']['hostname'], 'dbname' => $db['default']['database']);
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
示例12: __construct
public function __construct()
{
//cargamos la configuración de base de datos de codeigniter
require APPPATH . "config/database.php";
//utilizamos el namespace Entities para mapear el directorio models
$entitiesClassLoader = new ClassLoader('Entities', rtrim(APPPATH . "models"));
$entitiesClassLoader->register();
//utilizamos el namespace Proxies para mapear el directorio models/proxies
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
// Configuración y chaché
$config = new Configuration();
$cache = new ArrayCache();
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/entities'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Configuración Proxy
$config->setProxyDir(APPPATH . '/models/proxies');
$config->setProxyNamespace('Proxies');
// Habilitar el logger para obtener información de cada proceso
$logger = new EchoSQLLogger();
//$config->setSQLLogger($logger);
$config->setAutoGenerateProxyClasses(TRUE);
//configuramos la conexión con la base de datos utilizando las credenciales de nuestra app
$connectionOptions = array('driver' => 'pdo_mysql', 'user' => $db["default"]["username"], 'password' => $db["default"]["password"], 'host' => $db["default"]["hostname"], 'dbname' => $db["default"]["database"]);
// Creamos el EntityManager
$this->em = EntityManager::create($connectionOptions, $config);
}
示例13: __construct
public function __construct()
{
// load database configuration from CodeIgniter
require_once APPPATH.'config/database.php';
// Set up class loading. You could use different autoloaders, provided by your favorite framework,
// if you want to.
require_once APPPATH.'libraries/Doctrine/Common/ClassLoader.php';
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH.'libraries');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, '/'));
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('Proxies', APPPATH.'models/proxies');
$proxiesClassLoader->register();
//extension
$extensionClassLoader = new ClassLoader('DoctrineExtensions', APPPATH.'libraries/DoctrineExtensions/lib');
$extensionClassLoader->register();
// Set up caches
$config = new Configuration;
// Caching Configuration (5)
//if (APPLICATION_ENV == "development") {
$cache = new \Doctrine\Common\Cache\ArrayCache();
//} else {
// $cache = new \Doctrine\Common\Cache\ApcCache();
//}
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
// Set up driver
$Doctrine_AnnotationReader = new \Doctrine\Common\Annotations\AnnotationReader($cache);
$Doctrine_AnnotationReader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($Doctrine_AnnotationReader, APPPATH.'models');
$config->setMetadataDriverImpl($driver);
// Proxy configuration
$config->setProxyDir(APPPATH.'/models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
//$logger = new EchoSqlLogger;
//$config->setSqlLogger($logger);
$config->setAutoGenerateProxyClasses( TRUE );
// Database connection information
$connectionOptions = array(
'driver' => 'pdo_mysql',
'user' => $db['default']['username'],
'password' => $db['default']['password'],
'host' => $db['default']['hostname'],
'dbname' => $db['default']['database']
);
//$evm = new Doctrine\Common\EventManager();
// Create EntityManager
$this->em = EntityManager::create($connectionOptions, $config);//, $evm);
}
示例14: testClassLoaderCheckFileExists
public function testClassLoaderCheckFileExists()
{
$classLoader = new \Doctrine\Common\ClassLoader();
$classLoader->setBasePath('ClassLoaderTest', __DIR__);
$classLoader->setCheckFileExists(true);
// This would return a fatal error without check file exists true
$this->assertEquals($classLoader->loadClass('SomeInvalidClass'), false);
}
示例15: testGetClassLoader
public function testGetClassLoader()
{
$cl = new ClassLoader('ClassLoaderTest', __DIR__);
$cl->register();
$this->assertTrue(ClassLoader::getClassLoader('ClassLoaderTest\\ClassD') instanceof \Doctrine\Common\ClassLoader);
$this->assertNull(ClassLoader::getClassLoader('This\\Class\\Does\\Not\\Exist'));
$cl->unregister();
}