本文整理汇总了PHP中Doctrine\Common\ClassLoader::getIncludePath方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::getIncludePath方法的具体用法?PHP ClassLoader::getIncludePath怎么用?PHP ClassLoader::getIncludePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\ClassLoader
的用法示例。
在下文中一共展示了ClassLoader::getIncludePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* constructor
*/
public function __construct()
{
// load database configuration from CodeIgniter
require 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.'third_party/Doctrine/Common/ClassLoader.php';
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . '../vendor/doctrine');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', APPPATH . "models/Entities");
$entitiesClassLoader->register();
$proxiesClassLoader = new ClassLoader('proxies', APPPATH . 'models/proxies');
$proxiesClassLoader->register();
// Set up caches
$config = new Configuration();
//TODO this approach won't work always, developers may habe memcached installed, but not interested
//to use or server not running. Need to fix.
if (class_exists('Memcached')) {
$memcache = new \Memcached();
$memcache->addServer('127.0.0.1', 11211);
$cacheDriver = new \Doctrine\Common\Cache\MemcachedCache();
$cacheDriver->setMemcached($memcache);
} else {
if (extension_loaded('apc') && ini_get('apc.enabled')) {
$cacheDriver = new \Doctrine\Common\Cache\ApcCache();
} else {
$cacheDriver = new \Doctrine\Common\Cache\ArrayCache();
}
}
$config->setMetadataCacheImpl($cacheDriver);
$driverImpl = $config->newDefaultAnnotationDriver(array(APPPATH . 'models/Entities'));
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cacheDriver);
// Proxy configuration
$config->setProxyDir(APPPATH . 'models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
//$logger = new Doctrine\DBAL\Logging\CIProfiler();
//$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);
foreach ($driverImpl->getAllClassNames() as $class) {
require_once $entitiesClassLoader->getIncludePath() . "/" . $class . ".php";
}
//$this->generate_classes();
}
示例2: __construct
/**
* constructor
*/
public function __construct()
{
// load database configuration from CodeIgniter
require 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.'third_party/Doctrine/Common/ClassLoader.php';
$doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . '../vendor/doctrine');
$doctrineClassLoader->register();
$entitiesClassLoader = new ClassLoader('models', APPPATH . "models/Entities");
$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);
// Proxy configuration
$config->setProxyDir(APPPATH . 'models/proxies');
$config->setProxyNamespace('Proxies');
// Set up logger
//$logger = new Doctrine\DBAL\Logging\CIProfiler();
//$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);
foreach ($driverImpl->getAllClassNames() as $class) {
require_once $entitiesClassLoader->getIncludePath() . "/" . $class . ".php";
}
//$this->generate_classes();
}