当前位置: 首页>>代码示例>>PHP>>正文


PHP Setup::registerAutoloadDirectory方法代码示例

本文整理汇总了PHP中Doctrine\ORM\Tools\Setup::registerAutoloadDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Setup::registerAutoloadDirectory方法的具体用法?PHP Setup::registerAutoloadDirectory怎么用?PHP Setup::registerAutoloadDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\Tools\Setup的用法示例。


在下文中一共展示了Setup::registerAutoloadDirectory方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __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);
 }
开发者ID:sk8sta13,项目名称:Clients,代码行数:35,代码来源:Doctrine.php

示例2: __construct

 public function __construct()
 {
     // Set up class loading. You could use different autoloaders, provided by your favorite framework,
     // if you want to.
     $directory = APPPATH . "third_party/doctrine2-orm";
     if (!class_exists('Doctrine\\ORM\\Tools\\Setup', false)) {
         require $directory . '/Doctrine/ORM/Tools/Setup.php';
     }
     Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($directory);
     $doctrineClassLoader = new ClassLoader('Doctrine', APPPATH . 'libraries');
     $doctrineClassLoader->register();
     // Set up models loading
     $entitiesClassLoader = new ClassLoader('models', rtrim(APPPATH, "/"));
     $entitiesClassLoader->register();
     foreach (glob(APPPATH . 'modules/*', GLOB_ONLYDIR) as $m) {
         $module = str_replace(APPPATH . 'modules/', '', $m);
         $loader = new ClassLoader($module, APPPATH . 'modules');
         $loader->register();
     }
     $proxiesClassLoader = new ClassLoader('Proxies', APPPATH . 'models/proxies');
     $proxiesClassLoader->register();
     // Set up caches
     $this->config = new Configuration();
     $cache = new ArrayCache();
     //		$cache = new \Doctrine\Common\Cache\ApcCache;
     $this->config->setMetadataCacheImpl($cache);
     $this->config->setQueryCacheImpl($cache);
     // Set up models
     $models = array(APPPATH . 'models');
     foreach (glob(APPPATH . 'modules/*/models', GLOB_ONLYDIR) as $m) {
         array_push($models, $m);
     }
     $driverImpl = $this->config->newDefaultAnnotationDriver($models);
     $this->config->setMetadataDriverImpl($driverImpl);
     // Proxy configuration
     $this->config->setProxyDir(APPPATH . '/models/proxies');
     $this->config->setProxyNamespace('Proxies');
     // Set up logger
     //		$logger = new EchoSQLLogger;
     //		$this->config->setSQLLogger($logger);
     $this->config->setAutoGenerateProxyClasses(TRUE);
     // Database connection information
     // load database configuration from CodeIgniter
     // Is the config file in the environment folder?
     if (!defined('ENVIRONMENT') or !file_exists($file_path = APPPATH . 'config/' . ENVIRONMENT . '/database.php')) {
         if (!file_exists($file_path = APPPATH . 'config/database.php')) {
             show_error('The configuration file database.php does not exist.');
         }
     }
     include $file_path;
     if (!isset($db) or count($db) == 0) {
         show_error('No database connection settings were found in the database config file.');
     }
     $this->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($this->connectionOptions, $this->config);
 }
开发者ID:NaszvadiG,项目名称:ci-beam,代码行数:57,代码来源:Doctrine.php

示例3: __construct

 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
     $config = Setup::createAnnotationMetadataConfiguration($metadata_paths, $dev_mode = true, $proxies_dir);
     $this->em = EntityManager::create($connection_options, $config);
     $loader = new ClassLoader($models_namespace, $models_path);
     $loader->register();
 }
开发者ID:andrewolobo,项目名称:mpTracker,代码行数:19,代码来源:Doctrine.php

示例4: testDirectoryAutoload

 public function testDirectoryAutoload()
 {
     Setup::registerAutoloadDirectory(__DIR__ . "/../../../../../lib/vendor/doctrine-common/lib");
     $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions()));
 }
开发者ID:rfc1483,项目名称:padel,代码行数:5,代码来源:SetupTest.php

示例5: array

        $cf = $config->toArray();
        Conjoon_Log::init($cf['log']);
    }
}
// set as default adapter for all db operations
Conjoon_Db_Table::setDefaultAdapter(Zend_Db::factory($config->database->adapter, array('host' => $config->database->params->host, 'username' => $config->database->params->username, 'password' => $config->database->params->password, 'dbname' => $config->database->params->dbname, 'port' => $config->database->params->port, 'driver_options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'))));
// set tbl prefix
Conjoon_Db_Table::setTablePrefix($config->database->table->prefix);
// +------------------------------------------------------------------------
// | DOCTRINE
// +------------------------------------------------------------------------
/**
 * @see Doctrine\ORM\Tools\Setup
 */
require_once 'Doctrine/ORM/Tools/Setup.php';
\Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($LIBRARY_PATH_BOOTSTRAP . '/vendor/doctrine/');
/**
 * @see Doctrine\Common\ClassLoader
 */
require_once 'Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Conjoon', $LIBRARY_PATH_BOOTSTRAP . '/src/corelib/php/library/');
$classLoader->register();
$doctrineParams = array('driver' => 'pdo_mysql', 'host' => $config->database->params->host, 'user' => $config->database->params->username, 'password' => $config->database->params->password, 'dbname' => $config->database->params->dbname, 'port' => $config->database->params->port, 'driverOptions' => array(\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8'));
$doctrineCacheInstances = array('query_cache' => null, 'metadata_cache' => null);
// doctrine cache settings
if ($config->application->doctrine->cache->enabled) {
    $doctrineCacheSections = array('query_cache' => $config->application->doctrine->cache->query_cache, 'metadata_cache' => $config->application->doctrine->cache->metadata_cache);
    foreach ($doctrineCacheSections as $doctrineCacheKey => $doctrineCacheSection) {
        if ($doctrineCacheSection->enabled) {
            // if we do not find a valid extension, we'll be usind
            // an array cache later on
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:31,代码来源:index.php

示例6: registerAutoload

 /**
  * [USADA POR EL SISTEMA]
  */
 public static function registerAutoload()
 {
     \Doctrine\ORM\Tools\Setup::registerAutoloadDirectory(__DIR__ . '/../../Doctrine');
 }
开发者ID:williamamed,项目名称:Raptor2,代码行数:7,代码来源:Store.php

示例7: array

    if (!file_exists($classLoaderBasePath)) {
        print 'Error: Could not find classloader base path: ' . $classLoaderBasePath . "\n";
        exit;
    }
}
if ($props['doctrine.directory'] !== 'pear') {
    set_include_path($props['doctrine.directory'] . PATH_SEPARATOR . get_include_path());
}
use Doctrine\ORM\Tools\Setup;
require_once "Doctrine/ORM/Tools/Setup.php";
if ($props['doctrine.directory'] === 'pear') {
    // use pear supplied doctrine
    Setup::registerAutoloadPEAR();
} else {
    // use maven artifacts
    Setup::registerAutoloadDirectory($props['doctrine.directory']);
}
// enable classloading for the app
$classLoader = new \Doctrine\Common\ClassLoader($props['doctrine.classloader.name'], $classLoaderBasePath);
$classLoader->register();
// create a simple "default" Doctrine ORM configuration for annotation mapping
$isDevMode = $props['dev.mode'];
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__ . '/MyApp/Entities'), $isDevMode);
// or if you prefer xml/yaml annotations
//$config = Setup::createXMLMetadataConfiguration(array(__DIR__."/config/xml"), $isDevMode);
//$config = Setup::createYAMLMetadataConfiguration(array(__DIR__."/config/yaml"), $isDevMode);
// database configuration
switch ($props['db.driver']) {
    case "mysql":
        $conn = array('driver' => 'pdo_mysql', 'host' => $props['db.host'], 'port' => $props['db.port'], 'dbname' => $props['db.name'], 'user' => $props['db.user'], 'password' => $props['db.password']);
        break;
开发者ID:gqtan,项目名称:maven-php-plugin,代码行数:31,代码来源:bootstrap_doctrine.php


注:本文中的Doctrine\ORM\Tools\Setup::registerAutoloadDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。