本文整理汇总了PHP中Zend_Loader_Autoloader类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Loader_Autoloader类的具体用法?PHP Zend_Loader_Autoloader怎么用?PHP Zend_Loader_Autoloader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Loader_Autoloader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initAutoloaderNamespaces
public function _initAutoloaderNamespaces()
{
require_once APPLICATION_PATH . '/../library/vendor/Doctrine/lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
$autoloader = \Zend_Loader_Autoloader::getInstance();
$fmmAutoloader = new \Doctrine\Common\ClassLoader('Bisna');
$autoloader->pushAutoloader(array($fmmAutoloader, 'loadClass'), 'Bisna');
}
示例2: init
public function init()
{
$options = $this->getOptions();
if (isset($options['base_path'])) {
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
$options = array('plugins' => array('Variables', 'File' => array('base_path' => $options['base_path']), 'Memory', 'Time', 'Registry', 'Exception'));
# Instantiate the database adapter and setup the plugin.
# Alternatively just add the plugin like above and rely on the autodiscovery feature.
if ($this->hasPluginResource('db')) {
$this->bootstrap('db');
$db = $this->getPluginResource('db')->getDbAdapter();
$options['plugins']['Database']['adapter'] = $db;
}
# Setup the cache plugin
if ($this->hasPluginResource('cache')) {
$this->bootstrap('cache');
$cache = $this->getPluginResource('cache')->getDbAdapter();
$options['plugins']['Cache']['backend'] = $cache->getBackend();
}
$debug = new ZFDebug_Controller_Plugin_Debug($options);
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);
}
}
示例3: _initAutoload
protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(array('namespace' => '', 'basePath' => APPLICATION_PATH));
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace(array('Flux_', 'Iste_', 'Spip_'));
return $moduleLoader;
}
示例4: _initAutoLoader
/**
* _initAutoLoader
*
* @return Zend_Loader_Autoloader
*/
public function _initAutoLoader()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH, 'namespace' => 'Application', 'resourceTypes' => array('plugin' => array('path' => 'plugins/', 'namespace' => 'Plugin'), 'form' => array('path' => 'forms/', 'namespace' => 'Form'), 'model' => array('path' => 'models/', 'namespace' => 'Model'))));
$autoloader->pushAutoloader($resourceLoader);
return $autoloader;
}
示例5: run
public static function run()
{
#echo get_include_path();
#exit();
try {
// 設定ファイル読み込み
$config = new Zend_Config_Ini(INSTALL_DIR . 'application/configs/config.ini', 'production');
// Zend_Loader の設定(ファイル自動読み込み)
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
Zend_Registry::set($config->registry->config, $config);
$view = new Tokyofr_View_Smarty($config->smarty->template_dir, $config->smarty->toArray());
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view)->setViewBasePathSpec($view->getEngine()->template_dir[0]);
$viewRenderer->setViewScriptPathSpec(':controller/:action.:suffix');
$viewRenderer->setViewScriptPathNoControllerSpec(':action.:suffix');
$viewRenderer->setViewSuffix('phtml');
Tokyofr_Controller_Front::run($config->path->controller);
} catch (Zend_Exception $e) {
//var_dump($e->getMessage());
exit("error.");
} catch (Exception $e) {
//var_dump($e->getMessage());
exit('error02');
}
}
示例6: _initDoctrine
protected function _initDoctrine()
{
require_once LIBRARY_PATH . '/Doctrine/Common/ClassLoader.php';
$autoloader = \Zend_Loader_Autoloader::getInstance();
$fmmAutoloader = new \Doctrine\Common\ClassLoader();
$autoloader->pushAutoloader(array($fmmAutoloader, 'loadClass'));
$options = $this->getOptions();
$config = new Doctrine\ORM\Configuration();
$config->addCustomDatetimeFunction('YEAR', 'Doctrine\\Extensions\\Query\\Mysql\\Year');
$config->addCustomDatetimeFunction('MONTH', 'Doctrine\\Extensions\\Query\\Mysql\\Month');
$config->addCustomDatetimeFunction('DAY', 'Doctrine\\Extensions\\Query\\Mysql\\Day');
$config->addCustomStringFunction('DATEDIFF', 'Doctrine\\Extensions\\Query\\Mysql\\DateDiff');
$config->addCustomStringFunction('DATE_FORMAT', 'Doctrine\\Extensions\\Query\\Mysql\\DateFormat');
$config->addCustomStringFunction('IF', 'Doctrine\\Extensions\\Query\\Mysql\\IfElse');
$config->addCustomStringFunction('GROUP_CONCAT', 'Doctrine\\Extensions\\Query\\Mysql\\GroupConcat');
$config->addCustomStringFunction('IFNULL', 'Doctrine\\Extensions\\Query\\Mysql\\IfNull');
$config->setProxyDir($options['doctrine']['metadata']['proxyDir']);
$config->setProxyNamespace('Doctrine\\Proxy');
$config->setAutoGenerateProxyClasses(true);
$config->setAutoGenerateProxyClasses(APPLICATION_ENV == 'development');
//$driverImpl = $config->newDefaultAnnotationDriver($options['metadata']['entityDir']);
$driverImpl = new Doctrine\ORM\Mapping\Driver\YamlDriver($options['doctrine']['metadata']['entityDir']);
$config->setMetadataDriverImpl($driverImpl);
$cache = new Doctrine\Common\Cache\ArrayCache();
$config->setMetadataCacheImpl($cache);
$config->setQueryCacheImpl($cache);
$evm = new Doctrine\Common\EventManager();
$em = Doctrine\ORM\EntityManager::create($options['doctrine']['db'], $config, $evm);
Zend_Registry::set('doctrine', $em);
return $em;
}
示例7: _initCustomUrls
protected function _initCustomUrls()
{
$this->bootstrap('frontController');
Zend_Loader_Autoloader::getInstance()->registerNamespace('Customurl')->registerNamespace('Customurl');
$plugin = new Customurl_ControllerPlugin();
$this->getResource('frontController')->registerPlugin($plugin);
}
示例8: init
public static function init($_host, $_user, $_pass, $dbname)
{
if (!isset($_host)) {
$_host = SJB_System::getSystemSettings('DBHOST');
}
if (!isset($_user)) {
$_user = SJB_System::getSystemSettings('DBUSER');
}
if (!isset($_pass)) {
$_pass = SJB_System::getSystemSettings('DBPASSWORD');
}
if (!isset($dbname)) {
$dbname = SJB_System::getSystemSettings('DBNAME');
}
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Zend');
$db = new Adapter(array('driver' => self::getDBAdapter(), 'host' => $_host, 'database' => $dbname, 'username' => $_user, 'password' => $_pass, 'options' => array('buffer_results' => true)));
try {
$connection = $db->driver->getConnection();
$connection->connect();
$sql = new Sql($db);
Zend_Registry::set('db', $db);
Zend_Registry::set('sql', $sql);
} catch (Exception $ex) {
die("Could not connect to database");
}
$db->createStatement("SET NAMES '" . SJB_System::getSystemSettings('MYSQL_CHARSET') . "'")->execute();
}
示例9: __construct
public function __construct($addr = "127.0.0.1", $port = 8080)
{
$this->port = $port;
$this->addr = $addr;
// Setup basic stuff
error_reporting(E_ALL & ~E_NOTICE);
$base = realpath(dirname(__FILE__) . '/../');
$paths = array('.', realpath($base . '/library'), get_include_path());
$this->base = $base;
// Setup autoloading ...
set_include_path(implode(PATH_SEPARATOR, $paths));
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('EvHttp_');
$resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => realpath($base . '/application'), 'namespace' => '', 'resourceTypes' => array('model' => array('namespace' => 'Model', 'path' => 'models/'), 'api' => array('namespace' => 'Service', 'path' => 'apis/'))));
// Load config
$this->config = new Zend_Config_Ini($this->base . '/deploy/config.ini', 'default');
Zend_Registry::set('config', $this->config);
// Connect database
$dbType = $this->config->database->type;
$params = $this->config->database->toArray();
$db = Zend_Db::factory($dbType, $params);
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db', $db);
// Setup Xml-Rpc Server
$this->xmlrpc_server = new Zend_XmlRpc_Server();
$this->xmlrpc_server->setClass('Service_Poll', 'poll');
Zend_XmlRpc_Server_Fault::attachFaultException('Exception');
// Setup Json-Rpc Server
$this->jsonrpc_server = new Zend_Json_Server();
$this->jsonrpc_server->setClass('Service_Poll', 'poll')->setAutoEmitResponse(false)->setTarget('/jsonrpc')->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
}
示例10: init
/**
* Initializes the Doctrine Resource. This is done in four steps:
* <ul>
* <li>Register Doctrines own autoloader with the Zend_Loader stack</li>
* <li>Instantiate the Doctrine_Manager</li>
* <li>Open defined connections</li>
* <li>Load model paths</li>
* </ul>
* @return Doctrine_Manager
*/
public function init()
{
// Get the Resource options
$options = $this->getOptions();
// Register the Doctrine autoloader
require_once 'Doctrine.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->pushAutoloader(array('Doctrine', 'autoload'));
$autoloader->pushAutoloader(array('Doctrine_Core', 'modelsAutoload'));
// Initialize the Doctrine Manager
$this->_manager = Doctrine_Manager::getInstance();
// Check for manager attributes in the options
if (array_key_exists('manager', $options)) {
$managerOptions = $options['manager'];
if (array_key_exists('attributes', $managerOptions) && is_array($managerOptions['attributes'])) {
$this->_setManagerAttributes($managerOptions['attributes']);
}
}
// Open defined connections
if (isset($options['connections']) && is_array($options['connections']) && !empty($options['connections'])) {
foreach ($options['connections'] as $connectionName => $connectionOptions) {
$this->_openConnection($connectionName, $connectionOptions);
}
}
// Load models
if (array_key_exists('paths', $options)) {
$pathsOptions = $options['paths'];
if (array_key_exists('models_path', $pathsOptions) && !empty($pathsOptions['models_path'])) {
$this->_loadModels($pathsOptions['models_path']);
}
}
return $this->_manager;
}
示例11: _initZFDebug
protected function _initZFDebug()
{
// Setup autoloader with namespace
$autoloader = \Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
// Ensure the front controller is initialized
$this->bootstrap('FrontController');
// Retrieve the front controller from the bootstrap registry
$front = $this->getResource('FrontController');
// Only enable zfdebug if options have been specified for it
if ($this->hasOption('zfdebug')) {
// Create ZFDebug instance
$zfDebug = new \ZFDebug\Controller\Plugin\Debug($this->getOption('zfdebug'));
// Register ZFDebug with the front controller
$front->registerPlugin($zfDebug);
}
// In application.ini do the following:
//
// [development : production]
// zfdebug.plugins.Variables = null
// zfdebug.plugins.Time = null
// zfdebug.plugins.Memory = null
// ...
// Plugins that take objects as parameters like Database and Cache
// need to be registered manually:
$zfDebug->registerPlugin(new \ZFDebug\Controller\Plugin\Debug\Plugin\Database($db));
// Alternative configuration without application.ini
$options = ['plugins' => ['variables', 'database', 'file' => ['basePath' => '/Library/WebServer/Documents/budget', 'myLibrary' => 'Scienta'], 'memory', 'time', 'registry', 'exception']];
$zfDebug = new \ZFDebug\Controller\Plugin\Debug($options);
// Register ZFDebug with the front controller
$front->registerPlugin($zfDebug);
}
示例12: bootstrap
public function bootstrap($env)
{
putenv('RUN_CLI_MODE=true');
define('RUN_CLI_MODE', true);
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../../../../application'));
// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : $env);
// bootstrap include_path and constants
require realpath(APPLICATION_PATH . '/../library/library.php');
/** Zend_Application */
require_once 'Zend/Application.php';
require_once 'Centurion/Application.php';
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance()->registerNamespace('Centurion_')->setDefaultAutoloader(create_function('$class', "include str_replace('_', '/', \$class) . '.php';"));
$classFileIncCache = realpath(APPLICATION_PATH . '/../data/cache') . '/pluginLoaderCache.tmp';
if (file_exists($classFileIncCache)) {
$fp = fopen($classFileIncCache, 'r');
flock($fp, LOCK_SH);
$data = file_get_contents($classFileIncCache);
flock($fp, LOCK_UN);
fclose($fp);
$data = @unserialize($data);
if ($data !== false) {
Centurion_Loader_PluginLoader::setStaticCachePlugin($data);
}
}
Centurion_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
// Create application, bootstrap, and run
$this->_application = new Centurion_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/');
$this->_application->bootstrap('db');
$this->_application->bootstrap('FrontController');
$this->_application->bootstrap('contrib');
}
示例13: init
/**
* Initialize
*/
public function init()
{
$doctrineConfig = $this->getOptions();
if (isset($doctrineConfig['compiled']) && $doctrineConfig['compiled'] == true && file_exists(APPLICATION_PATH . '/../library/Doctrine.compiled.php')) {
require_once 'Doctrine.compiled.php';
} else {
require_once 'Doctrine.php';
}
$loader = Zend_Loader_Autoloader::getInstance();
$loader->pushAutoloader(array('Doctrine', 'autoload'), 'Doctrine');
$manager = Doctrine_Manager::getInstance();
// set models to be autoloaded and not included (Doctrine::MODEL_LOADING_AGGRESSIVE)
$manager->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
// enable ModelTable classes to be loaded automatically
$manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
// enable validation on save()
$manager->setAttribute(Doctrine::ATTR_VALIDATE, Doctrine::VALIDATE_ALL);
// enable sql callbacks to make SoftDelete and other behaviours work transparently
$manager->setAttribute(Doctrine::ATTR_USE_DQL_CALLBACKS, true);
// enable automatic queries resource freeing
$manager->setAttribute(Doctrine_Core::ATTR_AUTO_FREE_QUERY_OBJECTS, true);
// connect to database
$manager->openConnection($doctrineConfig['connection_string']);
// set to utf8
$manager->connection()->setCharset('utf8');
if (isset($doctrineConfig['cache']) && $doctrineConfig['cache'] == true) {
$cacheDriver = new Doctrine_Cache_Apc();
$manager->setAttribute(Doctrine::ATTR_QUERY_CACHE, $cacheDriver);
}
return $manager;
}
示例14: __connect
public function __connect()
{
set_include_path(implode(PATH_SEPARATOR, array(WWW_ROOT . '/zend/library/', get_include_path())));
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$this->mail = new Zend_Mail_Storage_Imap(array('host' => $this->hostname, 'port' => $this->port, 'ssl' => $this->ssl, 'user' => $this->username, 'password' => $this->password));
}
示例15: _initAutoloader
protected function _initAutoloader()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('PHPExcel_');
$autoloader->registerNamespace('PHPExcel');
return $autoloader;
}