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


PHP AppHelper::Instance方法代碼示例

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


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

示例1: testRead

 /**
  * @depends testWrite
  */
 public function testRead()
 {
     $help = AppHelper::Instance();
     $drive = new File_d();
     $key = "testFile";
     $this->assertTrue($drive->enabled(), "is drive ok?(testRead)");
     $this->assertTrue($drive->Info() == $drive->Info(), "is drive ok?(testRead)");
     $this->assertEquals($this->_val, $drive->get($key), "get the cache with the key:" . $key);
     //傳入參數
     $options = array("prefix" => "newCache");
     $drive = new File_d($options);
     $this->assertEquals($this->_val . "newCache", $drive->get($key), "get the newCache with the key:" . $key);
     //關閉校驗和
     $this->assertEquals($this->_val, $drive->get($key . "noCheck"), "get the newCache with the key: noCheck" . $key);
     //關閉壓縮
     $this->assertEquals($this->_val, $drive->get($key . "noCompress"), "get the newCache with the key: noCompress" . $key);
     //都關閉
     $this->assertEquals($this->_val, $drive->get($key . "noAll"), "get the newCache with the key: noAll" . $key);
     //校驗出錯
     $options = array("temp" => __DIR__ . "/Md5");
     $drive = new File_d($options);
     //傳入時間,1秒,保證過期
     $drive->set($key . "expire", $this->_val, 1);
     sleep(2);
     //傳入時間,1秒,保證過期
     $this->assertEquals(false, $drive->get($key . "expire"), "the key will be out of time ");
     //校驗碼出錯
     $this->assertEquals(false, $drive->get($key . "testMd5"), "md5 error" . $key);
     //不存在的鍵
     $this->assertEquals(false, $drive->get($key), "the key not exist:" . $key);
     //TODO:
     \Registers\Driver::getInstance();
 }
開發者ID:BPing,項目名稱:PHPCbping,代碼行數:36,代碼來源:File_dTest.php

示例2: start

 /**
  * 啟動
  */
 public static function start()
 {
     /*
      * ------------------------------------------------------
      *  設置時區
      * ------------------------------------------------------
      */
     date_default_timezone_set("Asia/Shanghai");
     /*
      * ------------------------------------------------------
      * 安全程序:關掉魔法引號,過濾全局變量
      * ------------------------------------------------------
      */
     if (!is_php('5.4')) {
         ini_set('magic_quotes_runtime', 0);
         if ((bool) ini_get('register_globals')) {
             $_protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', '_SESSION', '_ENV', '_COOKIE', 'GLOBALS', 'HTTP_RAW_POST_DATA', '_protected', '_registered');
             $_registered = ini_get('variables_order');
             foreach (array('E' => '_ENV', 'G' => '_GET', 'P' => '_POST', 'C' => '_COOKIE', 'S' => '_SERVER') as $key => $superglobal) {
                 if (strpos($_registered, $key) === FALSE) {
                     continue;
                 }
                 foreach (array_keys(${$superglobal}) as $var) {
                     if (isset($GLOBALS[$var]) && !in_array($var, $_protected, TRUE)) {
                         $GLOBALS[$var] = NULL;
                     }
                 }
             }
         }
     }
     /*
      * ------------------------------------------------------
      *  異常處理,錯誤處理等,記錄錯誤日誌
      * ------------------------------------------------------
      */
     register_shutdown_function("_finish_handle");
     set_exception_handler("_exception_handle");
     set_error_handler("_error_handle");
     /*
      * ------------------------------------------------------
      *  注冊自動加載方法
      * ------------------------------------------------------
      */
     spl_autoload_register("Loader::autoload");
     Loader::setClassDir((array) AppHelper::Instance()->config("APP_AUTOLOAD_PATH"));
     Loader::setSuffix((array) AppHelper::Instance()->config("CLASS_FILE_SUFFIX"));
     /*
      * ------------------------------------------------------
      * ini 設置
      * ------------------------------------------------------
      */
     //默認字符編碼為UTF-8
     ini_set('default_charset', 'UTF-8');
     //日誌初始
     log_message(LOG_INFO, "初始處理完畢", \Utils\UtilFactory::getLogHandle());
     //運行核心程序
     log_message(LOG_INFO, "運行核心程序................");
     CommandHandler::run();
 }
開發者ID:BPing,項目名稱:PHPCbping,代碼行數:62,代碼來源:PHPCbping.class.php

示例3: tearDownAfterClass

 /**
  * 清理測試環境
  */
 public static function tearDownAfterClass()
 {
     parent::tearDownAfterClass();
     AppHelper::Instance()->config("APP_CTRL", 'TestControllers1/');
     $CPath = APPPATH . AppHelper::Instance()->config("APP_CTRL");
     rename($CPath, dirname(__FILE__) . "/TestControllers1/");
     unlink(APPPATH . "/temp/testForCmd.text");
 }
開發者ID:BPing,項目名稱:PHPCbping,代碼行數:11,代碼來源:CoreStartUpTest.php

示例4: __construct

 /**
  * 架構函數
  * @param array $arg_options 緩存參數
  * @access public
  * @throws
  */
 public function __construct($arg_options = array())
 {
     if (!$this->_enabled()) {
         throw new \Exception("no support:" . $this->info());
     }
     $this->_appHelper = \AppHelper::Instance();
     $this->_options = $arg_options;
 }
開發者ID:BPing,項目名稱:PHPCbping,代碼行數:14,代碼來源:Driver.absclass.php

示例5: getLogHandle

 public static function getLogHandle()
 {
     $log = Logs::getInstance();
     $logPath = \AppHelper::Instance()->config("LOG_PATH");
     $log->init(BASEPATH . $logPath . "log.log");
     $log->logInfo("返回日誌句柄");
     return $log;
 }
開發者ID:BPing,項目名稱:PHPCbping,代碼行數:8,代碼來源:UtilFactory.class.php

示例6: testConfig

 public function testConfig()
 {
     try {
         $ah = AppHelper::Instance();
         $config = (include "App.config.php");
         //讀取係統配置
         $this->assertEquals($config["USER_CONFIG_FILE_PATH"], $ah->config("USER_CONFIG_FILE_PATH"), "load system's config fail");
         //讀取不存在
         $this->assertTrue(null === $ah->config("NO_EXIST"), "read the attributes which no exist");
         //添加不存在的配置屬性
         $ah->config("NO_EXIST", True);
         $this->assertTrue($ah->config("NO_EXIST"), "add the attributes which no exist");
         //更變已存在的值
         $ah->config("NO_EXIST", False);
         $this->assertTrue(!$ah->config("NO_EXIST"), "update the attributes which no exist");
     } catch (\Exception $e) {
         $this->assertTrue(false, "some error  happen when run the test testConfig: " . $e->getMessage());
     }
 }
開發者ID:BPing,項目名稱:PHPCbping,代碼行數:19,代碼來源:AppHelperTest.php

示例7: getController

 /**
  * 解析命令新建對應命令控製器實例
  *
  * @param Context $arg_context 上下文 (請求內容)
  *
  * @return Controller
  * @throws \Exceptions\ResolverException
  */
 function getController(Context $arg_context)
 {
     $cmd = $arg_context->Params("cmd");
     $step = DIRECTORY_SEPARATOR;
     if (!$cmd) {
         $cmd = self::$_default_cmd;
     }
     //校驗命令格式 TODO:可以在Params上校驗
     $cmd_filter = AppHelper::Instance()->config("CMD_FILTER");
     if ($cmd_filter && preg_match($cmd_filter, $cmd) != 1) {
         throw new \Exceptions\ResolverException("Command cannot pass filter");
     }
     //如果存在‘.’ 則替換成文件分隔符,
     //實現控製器目錄下多級組合
     $cmd = trim(str_replace(array("."), $step, $cmd));
     //應用根目錄,控製器目錄,文件後綴名
     $app_root = rtrim(self::$_AppPath, ' \\/');
     $app_ctrl = self::$_ctrl_namespace;
     $ctrl_suffix = AppHelper::Instance()->config("CTRL_FILE_SUFFIX");
     //構建文件目錄和類
     $file_path = $app_root . $step . $app_ctrl . $step . $cmd . $ctrl_suffix;
     $class_name = "\\{$app_ctrl}\\" . (strripos($cmd, $step) ? substr($cmd, strripos($cmd, $step) + 1) : $cmd);
     //     echo "\n", $file_path, "\n", $class_name, "\n";
     if (!file_exists($file_path)) {
         throw new \Exceptions\ResolverException("Command file '{$cmd}' not found");
     }
     @(require_once "{$file_path}");
     if (!class_exists("{$class_name}")) {
         throw new \Exceptions\ResolverException("Command '{$cmd}' not found");
     }
     $cmd_class = new ReflectionClass("{$class_name}");
     if (!$cmd_class->isSubclassOf(self::$_base_cmd)) {
         throw new \Exceptions\ResolverException("Command '{$cmd}' is not a command");
     }
     return $cmd_class->newInstance();
 }
開發者ID:BPing,項目名稱:PHPCbping,代碼行數:44,代碼來源:ControlResolver.class.php

示例8: testNoFilter

 /**
  * 控製器無法通過過濾器異常
  *
  * @expectedException        Exceptions\ResolverException
  * @expectedExceptionMessage Command cannot pass filter
  */
 public function testNoFilter()
 {
     AppHelper::Instance()->config("CMD_FILTER", '/Controller$/');
     $_GET["cmd"] = "NoClassExist";
     $context = new Context();
     $ctrl_r = new ControlResolver();
     $ctrl = $ctrl_r->getController($context);
 }
開發者ID:BPing,項目名稱:PHPCbping,代碼行數:14,代碼來源:CommandTest.php


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