當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Yaf_Loader::getInstance方法代碼示例

本文整理匯總了PHP中Yaf_Loader::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Yaf_Loader::getInstance方法的具體用法?PHP Yaf_Loader::getInstance怎麽用?PHP Yaf_Loader::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Yaf_Loader的用法示例。


在下文中一共展示了Yaf_Loader::getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _initPlugin

 public function _initPlugin(Yaf_Dispatcher $dispatcher)
 {
     // set include paths of the system.
     set_include_path(get_include_path() . PATH_SEPARATOR . Yaf_Loader::getInstance()->getLibraryPath());
     /* register a billrun plugin system from config */
     $config = Yaf_Application::app()->getConfig();
     if (isset($config->plugins)) {
         $plugins = $config->plugins->toArray();
         $dispatcher = Billrun_Dispatcher::getInstance();
         foreach ($plugins as $plugin) {
             Billrun_Log::getInstance()->log("Load plugin " . $plugin, Zend_log::DEBUG);
             $dispatcher->attach(new $plugin());
         }
     }
     if (isset($config->chains)) {
         $chains = $config->chains->toArray();
         $dispatcherChain = Billrun_Dispatcher::getInstance(array('type' => 'chain'));
         foreach ($chains as $chain) {
             Billrun_Log::getInstance()->log("Load plugin " . $chain, Zend_log::DEBUG);
             $dispatcherChain->attach(new $chain());
         }
     }
     // make the base action auto load (required by controllers actions)
     Yaf_Loader::getInstance(APPLICATION_PATH . '/application/helpers')->registerLocalNamespace('Action');
 }
開發者ID:kalburgimanjunath,項目名稱:system,代碼行數:25,代碼來源:Bootstrap.php

示例2: init

 /**
  * method to control and navigate the user to the right view
  */
 public function init()
 {
     if (APPLICATION_ENV === 'prod') {
         // TODO: set the branch through config
         $branch = 'production';
         if (file_exists(APPLICATION_PATH . '/.git/refs/heads/' . $branch)) {
             $this->commit = rtrim(file_get_contents(APPLICATION_PATH . '/.git/refs/heads/' . $branch), "\n");
         } else {
             $this->commit = md5(date('ymd'));
         }
     } else {
         $this->commit = md5(time());
     }
     $this->baseUrl = $this->getRequest()->getBaseUri();
     $this->addCss($this->baseUrl . '/css/bootstrap.min.css');
     $this->addCss($this->baseUrl . '/css/bootstrap-datetimepicker.min.css');
     $this->addCss($this->baseUrl . '/css/bootstrap-switch.css');
     $this->addCss($this->baseUrl . '/css/bootstrap-multiselect.css');
     $this->addCss($this->baseUrl . '/css/jsoneditor.css');
     $this->addCss($this->baseUrl . '/css/main.css');
     $this->addJs($this->baseUrl . '/js/vendor/bootstrap.min.js');
     $this->addJs($this->baseUrl . '/js/plugins.js');
     $this->addJs($this->baseUrl . '/js/moment.js');
     $this->addJs($this->baseUrl . '/js/bootstrap-datetimepicker.min.js');
     $this->addJs($this->baseUrl . '/js/jquery.jsoneditor.js');
     $this->addJs($this->baseUrl . '/js/bootstrap-multiselect.js');
     $this->addJs($this->baseUrl . '/js/bootstrap-switch.js');
     $this->addJs($this->baseUrl . '/js/jquery.csv-0.71.min.js');
     $this->addJs($this->baseUrl . '/js/main.js');
     Yaf_Loader::getInstance(APPLICATION_PATH . '/application/helpers')->registerLocalNamespace('Admin');
 }
開發者ID:ngchie,項目名稱:system,代碼行數:34,代碼來源:Admin.php

示例3: initContext

 private static function initContext()
 {
     // set timezone
     date_default_timezone_set('PRC');
     // page start time,use $_SERVER['REQUEST_TIME'] instead above PHP 5.4+
     define('REQUEST_TIME_US', intval(microtime(true) * 1000000));
     // ODP pre-defined
     define('IS_ODP', true);
     define('ROOT_PATH', realpath(dirname(__FILE__) . '/../../../'));
     define('CONF_PATH', ROOT_PATH . '/conf');
     define('DATA_PATH', ROOT_PATH . '/data');
     define('BIN_PATH', ROOT_PATH . '/php/bin');
     define('LOG_PATH', ROOT_PATH . '/log');
     define('APP_PATH', ROOT_PATH . '/app');
     define('TPL_PATH', ROOT_PATH . '/template');
     define('LIB_PATH', ROOT_PATH . '/php/phplib');
     define('WEB_ROOT', ROOT_PATH . '/webroot');
     define('PHP_EXEC', BIN_PATH . '/php');
     $app_name == null && ($app_name = self::getAppName()) == null && ($app_name = 'unknown-app');
     define('ODP_APP', $app_name);
     define('APP', ODP_APP);
     $loader = \Yaf_Loader::getInstance(null, LIB_PATH);
     //var_dump($loader);
     define('CLIENT_IP', \Odp\Ip::getClientIp());
     define('USER_IP', \Odp\Ip::getUserIp());
     define('FRONTEND_IP', \Odp\Ip::getFrontendIp());
     // init autoloader
     // todo PSR-4 autoloader
     return true;
 }
開發者ID:fanscout,項目名稱:omz,代碼行數:30,代碼來源:Init.php

示例4: initApp

 /**
  * 初始化APP的數據
  * 
  * @param string $app 啟用的app的名稱,如:test
  */
 private static function initApp($app)
 {
     if (empty($app)) {
         return FALSE;
     }
     Ym_Timer::startRecord();
     define('YPP_APP', $app);
     define('YPP_APP_ROOT', YPP_DIR_APP . '/' . YPP_APP);
     define('YPP_APP_LIB', YPP_APP_ROOT . '/library');
     define('YPP_APP_LOG', YPP_DIR_LOG . '/' . YPP_APP);
     // 聲明loader,加載APP類文件
     Yaf_Loader::getInstance(YPP_APP_LIB);
     // 初始化配置
     Ym_Config::init();
     $env = Ym_Config::getAppItem('env:monitor.env');
     if ($env) {
         define('YPP_APP_ENV', $env);
     } else {
         define('YPP_APP_ENV', 'dev');
     }
     // 初始化日誌
     if (YPP_APP_ENV == 'pro') {
         $logConf['levels'] = array('debug' => 1, 'warning' => 4, 'error' => 5, 'fatal' => 6, 'alert' => 7, 'emergency' => 8);
     }
     $logConf['logPath'] = YPP_APP_LOG;
     $logConf['logFile'] = YPP_APP;
     Ym_Logger::init($logConf);
     //Ym_Logger::info('test');
     // 加載application.ini
     self::$app = new Yaf_Application(YPP_DIR_CONF . '/app/' . YPP_APP . '/application.ini');
 }
開發者ID:kaka987,項目名稱:YoungYaf,代碼行數:36,代碼來源:Init.php

示例5: initYafBySooh

 /**
  * 
  * @param \Yaf_Dispatcher $dispatcher
  * @param  string $jqueryVer 使用的jquery文件,默認值:jquery-1.11.2.min.js
  * @return view
  */
 public static function initYafBySooh($dispatcher, $jqueryVer = 'jquery-1.11.2.min.js')
 {
     $router = $dispatcher->getRouter();
     $router->addRoute("byVar", new \Yaf_Route_Supervar(SOOH_ROUTE_VAR));
     \Yaf_Loader::getInstance()->registerLocalNameSpace($GLOBALS['CONF']['localLibs']);
     $req = $dispatcher->getRequest();
     $tmp = $req->get('__ONLY__');
     if ($tmp == 'body') {
         \SoohYaf\Viewext::$bodyonly = true;
     }
     $tmp = trim($req->get('__VIEW__'));
     //html(default),wap,  json
     define('VIW_INC_PATH', APP_PATH . '/application/views/_inc/');
     \SoohYaf\Viewext::$jqueryVer = $jqueryVer;
     if (!empty($tmp)) {
         $tmp = strtolower($tmp);
         \Sooh\Base\Ini::getInstance()->viewRenderType($tmp);
         if ($tmp == 'jsonp') {
             \Sooh\Base\Ini::getInstance()->initGobal(array('nameJsonP' => $req->get('jsonp', 'jsonp')));
         }
     }
     //		$tmp = $dispatcher->getRequest()->get('__GZIP__');
     //		if(!empty($tmp)){
     //			$tmp = strtolower ($tmp);
     //			if($tmp=='gzip')define("ZIP_OUTPUT",$tmp);
     //		}
     $view = new \SoohYaf\Viewext(null);
     $dispatcher->setView($view);
     $dispatcher->registerPlugin(new SoohPlugin());
     return $view;
 }
開發者ID:hillstill,項目名稱:soohyaf,代碼行數:37,代碼來源:SoohPlugin.php

示例6: init

 /**
  * initialize method for yaf controller (instead of constructor)
  */
 public function init()
 {
     // all output will be store at class output class
     $this->output = new stdClass();
     $this->getView()->output = $this->output;
     // set the actions autoloader
     Yaf_Loader::getInstance(APPLICATION_PATH . '/application/helpers')->registerLocalNamespace("Action");
     $this->setActions();
     $this->setOutputMethod();
 }
開發者ID:ngchie,項目名稱:system,代碼行數:13,代碼來源:Api.php

示例7: _initLoader

 public function _initLoader(Yaf_Dispatcher $dispatcher)
 {
     //        echo 'aaaa';
     //        exit;
     $autoload = Yaf_Loader::getInstance();
     $autoload->registerLocalNameSpace(array("Foo", "Bar"));
     //$autoload->autoload('Foo_Dummy_Bar');
     $a = new Foo\Dummy\Bar();
     //$a->abc();
     //        echo 'aaaa';
     //        exit;
     //var_dump(class_exists('Foo_Dummy_Bar'));
 }
開發者ID:phpcandy,項目名稱:phpcandy.github.io,代碼行數:13,代碼來源:bootstrap.php

示例8: routerStartup

 public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     $this->config = Yaf_Application::app()->getConfig();
     $this->fileload = Yaf_Loader::getInstance();
     if (isset($this->config->application->autolibrary) && !empty($this->config->application->autolibrary)) {
         $autoclass = explode(',', $this->config->application->autolibrary);
         foreach ($autoclass as $v) {
             if (is_dir(APPLICATION_PATH . '/' . $v)) {
                 $this->getlist(APPLICATION_PATH . '/' . $v, 'class');
             } else {
                 throw new Exception(APPLICATION_PATH . '/' . $v . '不是目錄');
             }
         }
     }
     $this->fileload->setLibraryPath(APPLICATION_PATH . '/library', true);
 }
開發者ID:xingcuntian,項目名稱:yaf,代碼行數:16,代碼來源:Autoload.php

示例9: __construct

 public function __construct()
 {
     $rpc_dir = dirname(dirname(__DIR__)) . "/thrift";
     $yaf_load = Yaf_Loader::getInstance();
     $yaf_load->setLibraryPath($rpc_dir, true);
     require_once $rpc_dir . "/Thrift/ClassLoader/ThriftClassLoader.php";
     $loader = new Thrift\ClassLoader\ThriftClassLoader();
     $loader->registerNamespace('Thrift', $rpc_dir);
     $loader->registerNamespace('swoole', $rpc_dir);
     $loader->registerNamespace('Bin', $rpc_dir);
     $loader->registerDefinition('Bin', $rpc_dir);
     $loader->register();
     $config_obj = Yaf_Registry::get("config");
     $rpc_config = $config_obj->rpc->toArray();
     $socket = new Thrift\Transport\TSocket($rpc_config['host'], $rpc_config['port']);
     $this->transport = new Thrift\Transport\TFramedTransport($socket);
     $protocol = new Thrift\Protocol\TBinaryProtocol($this->transport);
     $this->transport->open();
     $this->client = new Bin\rpc\rpcClient($protocol);
     //$yaf_load->setLibraryPath(dirname($rpc_dir).'/library',true);
 }
開發者ID:qieangel2013,項目名稱:zys,代碼行數:21,代碼來源:RpcClient.php

示例10: bootstrap

 public function bootstrap()
 {
     $bootstrapClass = Yaf_Bootstrap_Abstract::YAF_DEFAULT_BOOTSTRAP;
     if (isset($this->_options['bootstrap'])) {
         $bootstrap = $this->_options['bootstrap'];
     } else {
         $bootstrap = $this->getAppDirectory() . DIRECTORY_SEPARATOR . $bootstrapClass . '.' . Yaf_G::get('ext');
     }
     $loader = Yaf_Loader::getInstance();
     if (Yaf_Loader::import($bootstrap)) {
         if (!class_exists($bootstrapClass)) {
             throw new Yaf_Exception('Couldn\'t find class Bootstrap in ' . $bootstrap);
         } else {
             $bootstrap = new $bootstrapClass();
             if (!$bootstrap instanceof Yaf_Bootstrap_Abstract) {
                 throw new Yaf_Exception('Expect a Yaf_Bootstrap_Abstract instance, ' . get_class($bootstrap) . ' give ');
             }
             if (version_compare(PHP_VERSION, '5.2.6') === -1) {
                 $class = new ReflectionObject($bootstrap);
                 $classMethods = $class->getMethods();
                 $methodNames = array();
                 foreach ($classMethods as $method) {
                     $methodNames[] = $method->getName();
                 }
             } else {
                 $methodNames = get_class_methods($bootstrap);
             }
             $initMethodLength = strlen(Yaf_Bootstrap_Abstract::YAF_BOOTSTRAP_INITFUNC_PREFIX);
             foreach ($methodNames as $method) {
                 if ($initMethodLength < strlen($method) && Yaf_Bootstrap_Abstract::YAF_BOOTSTRAP_INITFUNC_PREFIX === substr($method, 0, $initMethodLength)) {
                     $bootstrap->{$method}($this->_dispatcher);
                 }
             }
         }
     } else {
         throw new Yaf_Exception('Couldn\'t find bootstrap file ' . $bootstrap);
     }
     return $this;
 }
開發者ID:zhangjingpu,項目名稱:yaf-lib,代碼行數:39,代碼來源:Application.php

示例11: date_default_timezone_set

<?php

/**
 * Yaf client command
 *
 * @author      Xuexb<jeffxiaobo@foxmail.com>
 * @package     xiaobo/sh
 * @since       Version 1.0.1 @20140423
 * @copyright   Copyright (c) 2014, Yeahmobi, Inc.
 */
date_default_timezone_set('Asia/Shanghai');
define('YPP_APP', 'yeahmonitor');
define('YPP_APP_ROOT', YPP_DIR_APP . '/' . YPP_APP);
define('YPP_APP_LIB', YPP_APP_ROOT . '/library');
// 聲明loader
Yaf_Loader::getInstance(YPP_APP_LIB, YPP_ROOT_PHPLIB);
// 初始化配置和日誌類
Ym_Config::init();
$logConf['logPath'] = YPP_DIR_LOG . '/app/' . YPP_APP;
$logConf['logFile'] = YPP_APP;
Ym_Logger::init($logConf);
// 加載application.ini
$app = new Yaf_Application(YPP_DIR_CONF . '/app/' . YPP_APP . '/application.ini');
$app->bootstrap();
$app->getDispatcher()->dispatch(new Yaf_Request_Simple());
//方法2:不試用帶module的模式
//$controller = isset($argv[1]) ? $argv[1] : '';
//$action     = isset($argv[2]) ? $argv[2] : '';
//if (!$controller || !$action) {
//    die('Please Use like this: /dianyi/app/ypp/bin/php yafClient.php controller action [argv]' . PHP_EOL);
//}
開發者ID:kaka987,項目名稱:YoungYaf,代碼行數:31,代碼來源:yafClient.php

示例12: routerStartup

 /**
  * 路由開始事件
  *
  * @author         mrmsl <msl-138@163.com>
  * @date           2012-12-25 10:03:34
  * @lastmodify     2013-01-21 15:28:59 by mrmsl
  *
  * @param object $request  Yaf_Request_Http實例
  * @param object $response Yaf_Response_Http實例
  *
  * @return void 無返回值
  */
 public function routerStartup(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     Yaf_Loader::getInstance(LIB_PATH, LIB_PATH);
     //注冊項目及全局類庫路徑
     Yaf_Dispatcher::getInstance()->disableView();
     //禁用自動渲染模板輸出
     $this->_init();
 }
開發者ID:yunsite,項目名稱:yablog,代碼行數:20,代碼來源:Bootstrap.class.php

示例13: init

 /**
  * method to control and navigate the user to the right view
  */
 public function init()
 {
     $this->baseUrl = $this->getRequest()->getBaseUri();
     Yaf_Loader::getInstance(APPLICATION_PATH . '/application/helpers')->registerLocalNamespace('Admin');
 }
開發者ID:kalburgimanjunath,項目名稱:system,代碼行數:8,代碼來源:Admin.php

示例14: testCase037

 /**
  * @runInSeparateProcess
  */
 public function testCase037()
 {
     //ini_set('open_basedir', '.');
     //unfortunately setting open_basedir will make
     //phpunit to not work
     $globalDir = '/tmp/';
     if (!defined('YAF_MODE')) {
         Yaf_G::iniSet('yaf.library', $globalDir);
         Yaf_G::iniSet('yaf.lowcase_path', false);
     } else {
         ini_set('yaf.library', $globalDir);
         ini_set('yaf.lowcase_path', false);
     }
     $this->loader = Yaf_Loader::getInstance('/tmp');
     $this->loader->import("/tmp/1.php");
     try {
         $this->loader->autoload("Foo_Bar");
     } catch (PHPUnit_Framework_Error_Warning $e) {
         $this->assertContains('Could not find script /tmp/Foo/Bar.php', $e->getMessage());
     }
 }
開發者ID:ligboy,項目名稱:yaf-phpport,代碼行數:24,代碼來源:LoaderTest.php

示例15: _initBase

 function _initBase(Yaf_Dispatcher $dispatcher)
 {
     // 如果非命令行,則輸出 header 頭
     if (!core::is_cmd()) {
         header("Expires: 0");
         header("Cache-Control: private, post-check=0, pre-check=0, max-age=0");
         header("Pragma: no-cache");
         header('Content-Type: text/html; charset=UTF-8');
         header('X-Powered-By: http://www.lianchuangbrothers.com/');
         // 隱藏 PHP 版本 X-Powered-By: PHP/5.5.9
         header('Server: Microsoft-IIS/11.11');
     }
     //錯誤處理
     $dispatcher->setErrorHandler([get_class($this), 'error_handler']);
     //添加路由協議
     $dispatcher->getRouter()->addConfig((new Yaf_Config_Ini(APP_PATH . '/conf/routes.ini'))->routes);
     //注冊本地類
     Yaf_Loader::getInstance()->registerLocalNameSpace(['helper', 'misc']);
     // 加載數據庫
     Yaf_Registry::set('db', new medoo(Yaf_Registry::get("config")->get('database')->default->toArray()));
     //memcache
     //Yaf_Registry::set('memcache', new Memcache);
     //Yaf_Registry::get('memcache')->pconnect(Yaf_Registry::get("config")->get('memcache')->default->host, Yaf_Registry::get("config")->get('memcache')->default->port, 2.5);
     //redis
     Yaf_Registry::set('redis', new redis());
     //連接redis
     Yaf_Registry::get('redis')->pconnect(Yaf_Registry::get("config")->get('redis')->default->host, Yaf_Registry::get("config")->get('redis')->default->port, 2.5);
     //redis密碼
     Yaf_Registry::get('redis')->auth(Yaf_Registry::get("config")->get('redis')->default->password);
     //使用php內置的serialize/unserialize 方法對數據進行處理
     Yaf_Registry::get('redis')->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
     //rediskey加前綴
     Yaf_Registry::get('redis')->setOption(Redis::OPT_PREFIX, Yaf_Registry::get("config")->get('redis')->default->prefix);
     core::ob_start();
 }
開發者ID:290329416,項目名稱:guahao,代碼行數:35,代碼來源:Bootstrap.php


注:本文中的Yaf_Loader::getInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。