• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Yaf_Application类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Yaf_Application的典型用法代码示例。如果您正苦于以下问题:PHP Yaf_Application类的具体用法?PHP Yaf_Application怎么用?PHP Yaf_Application使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: testCase02

 /**
  * @runInSeparateProcess
  */
 public function testCase02()
 {
     if (!defined('YAF_MODE')) {
         //@todo for some reason this need to b true to pass the test
         Yaf_G::iniSet('yaf.use_spl_autoload', true);
         Yaf_G::iniSet('yaf.lowcase_path', false);
     } else {
         ini_set('yaf.use_spl_autoload', false);
         ini_set('yaf.lowcase_path', false);
     }
     $this->assertEquals('CLI', $this->request->getMethod());
     $this->assertEquals('index', $this->request->getModuleName());
     $this->assertEquals('dummy', $this->request->getControllerName());
     $this->assertEquals('index', $this->request->getActionName());
     $this->assertFalse($this->request->isDispatched());
     $this->assertTrue($this->request->isRouted());
     $this->request->setParam('name', 'Laruence');
     $this->assertEquals('Laruence', $this->request->getParam('name'));
     $this->assertNull($this->request->getParam('non-exists'));
     $this->assertTrue($this->request->isCli());
     $app = new Yaf_Application(array("application" => array("directory" => dirname(__FILE__))));
     try {
         $app->getDispatcher()->dispatch($this->request);
         $this->fail('An Yaf_Exception_LoadFailed_Controller ' . 'exception was not throwed');
     } catch (Exception $e) {
         $this->assertEquals('Could not find controller script ' . dirname(__FILE__) . '/controllers/Dummy.php', $e->getMessage());
     }
 }
开发者ID:ligboy,项目名称:yaf-phpport,代码行数:31,代码来源:SimpleTest.php


示例2: rpcserver_call

function rpcserver_call(swoole_process $worker)
{
    define('APPLICATION_PATH', dirname(dirname(__DIR__)) . "/application");
    define('THRIFT_DIR_PATH', dirname(APPLICATION_PATH) . "/thrift");
    require_once THRIFT_DIR_PATH . "/Thrift/ClassLoader/ThriftClassLoader.php";
    $loader = new Thrift\ClassLoader\ThriftClassLoader();
    $loader->registerNamespace('Thrift', THRIFT_DIR_PATH);
    $loader->registerNamespace('swoole', THRIFT_DIR_PATH);
    $loader->registerNamespace('Bin', THRIFT_DIR_PATH);
    $loader->registerDefinition('Bin', THRIFT_DIR_PATH);
    $loader->register();
    define('MYPATH', dirname(APPLICATION_PATH));
    $application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
    $application->bootstrap();
    $config_obj = Yaf_Registry::get("config");
    $rpc_config = $config_obj->rpc->toArray();
    define('SERVERIP', $rpc_config['ServerIp']);
    define('SERVERPORT', $rpc_config['port']);
    define('SERVERHOST', $rpc_config['host']);
    $service = new Bin\rpc\Handler();
    $processor = new Bin\rpc\rpcProcessor($service);
    $socket_tranport = new Thrift\Server\TServerSocket(SERVERIP, SERVERPORT);
    $out_factory = $in_factory = new Thrift\Factory\TFramedTransportFactory();
    $out_protocol = $in_protocol = new Thrift\Factory\TBinaryProtocolFactory();
    $server = new swoole\RpcServer($processor, $socket_tranport, $in_factory, $out_factory, $in_protocol, $out_protocol);
    $server->serve();
}
开发者ID:qieangel2013,项目名称:zys,代码行数:27,代码来源:RpcServer.php


示例3: __construct

 /**
  * init
  * 
  * @return void
  */
 public function __construct()
 {
     if (null === self::$_app) {
         $app = new Yaf_Application(APP_PATH . '/config/application.ini');
         self::$_app = $app->bootstrap();
     }
     parent::__construct();
 }
开发者ID:xiaoyueer98,项目名称:store.heimi.com,代码行数:13,代码来源:Test.php


示例4: testCase042

 /**
  * @runInSeparateProcess
  */
 public function testCase042()
 {
     $config = array("application" => array("directory" => TEST_APPLICATION_PATH, "dispatcher" => array("catchException" => 0, "throwException" => 1), "modules" => "module"));
     $app = new Yaf_Application($config);
     include dirname(__FILE__) . '/_files/testCase042.php';
     $request = new Yaf_Request_Http("/module/controller/index");
     try {
         $app->getDispatcher()->returnResponse(false)->dispatch($request);
     } catch (Yaf_Exception $e) {
         $this->assertEquals('exception', $e->getMessage());
     }
 }
开发者ID:ligboy,项目名称:yaf-phpport,代码行数:15,代码来源:ApplicationTest.php


示例5: hproseserver_call

function hproseserver_call(swoole_process $worker)
{
    define('APPLICATION_PATH', dirname(__DIR__) . "/application");
    define('MYPATH', dirname(APPLICATION_PATH));
    $application = new Yaf_Application(dirname(APPLICATION_PATH) . "/conf/application.ini");
    $application->bootstrap();
    $config_obj = Yaf_Registry::get("config");
    $hprose_config = $config_obj->hprose->toArray();
    $server = new Server("tcp://" . $hprose_config['ServerIp'] . ":" . $hprose_config['port']);
    $server->setErrorTypes(E_ALL);
    $server->setDebugEnabled();
    $server->addFunction('zys');
    $server->start();
}
开发者ID:qieangel2013,项目名称:zys,代码行数:14,代码来源:server.php


示例6: run

 public function run($params = array())
 {
     $app = new Yaf_Application(APP_PATH . "/conf/application.ini");
     $uri = Yaf_Dispatcher::getInstance()->getRequest()->getRequestUri();
     list($tmp, $module, $controller, $action) = explode('/', $uri);
     foreach ($params as $key => $value) {
         Yaf_Dispatcher::getInstance()->getRequest()->setParam($key, $value);
     }
     $request = new Yaf_Request_Simple("Api", $module, $controller, $action, $params);
     // $request = new Yaf_Request_Simple("Api", "User", "Index", "demo", array());
     // Yaf_Dispatcher::getInstance()->getRequest()->setParam('uid',123456);
     $response = $app->bootstrap()->getDispatcher()->returnResponse(TRUE)->dispatch($request);
     // $response = $app->bootstrap()->getDispatcher()->dispatch($request);
     return $response->getBody();
 }
开发者ID:sean0402,项目名称:yarf-framework,代码行数:15,代码来源:Service.php


示例7: callbackAction

 public function callbackAction()
 {
     $mediaqqmodel = new Media_QQModel($this->_basemodel, $this->_qqparam);
     $app_id = isset($_REQUEST['app_id']) ? trim($_REQUEST['app_id']) : '69948denMVMoBujYGLSFGUHbkvP7E3';
     $mediaqq = $mediaqqmodel->getApp($app_id);
     $APPID = $mediaqq['APPID'] && $mediaqq['APPKEY'] ? $mediaqq['APPID'] : $mediaqq['def_APPID'];
     $APPKEY = $mediaqq['APPID'] && $mediaqq['APPKEY'] ? $mediaqq['APPKEY'] : $mediaqq['def_APPKEY'];
     $redirect_uri = $this->_qqparam['redirect_uri'] . '?app_id=' . $mediaqq['app_id'];
     $state = md5($mediaqq['app_key']);
     $qcinit = new QQAPI_YafQQConnetAPI();
     $qc = new QC();
     $access_token = $qc->qq_callback($APPID, $redirect_uri, $APPKEY);
     echo $access_token . '----------';
     $openid = $qc->get_openid($access_token);
     echo $openid . '---------';
     $qqUser = $qc->my_get_userinfo($access_token, $openid, $APPID);
     if ($qqUser && $qqUser->nickname) {
         $media_user_id = $mediaqqmodel->saveUser($openid, $qqUser, $APPID);
         if ($media_user_id) {
             $usertokentime = date('Y-m-d H:i:s', time() + Yaf_Application::app()->getConfig()->application->usertokentime);
             $login_token = $mediaqqmodel->saveAccessToken($app_id, $access_token, $openid, $media_user_id, $usertokentime);
             if ($login_token) {
                 $url = $mediaqq['token_url'];
                 $concat = '&';
                 if (strpos($url, '?') === false) {
                     $concat = '?';
                 }
                 $url .= $concat . "token={$login_token}";
                 header("Location:{$url}");
             }
         }
     }
     exit;
 }
开发者ID:pbchen,项目名称:thirdLoginAPI,代码行数:34,代码来源:Qq.php


示例8: __construct

 public function __construct()
 {
     $config = Yaf_Application::app()->getConfig();
     Yaf_Loader::import('L_Wechat.class.php');
     $options = array('token' => $config['wx_token'], 'appid' => $config['wx_appID'], 'appsecret' => $config['wx_appSecret']);
     $this->wxSDK = new L_Wechat($options);
 }
开发者ID:xujunjiepk,项目名称:YOF,代码行数:7,代码来源:Com_Weixin.php


示例9: _initSmarty

 public function _initSmarty(Yaf_Dispatcher $dispatcher)
 {
     /* init smarty view engine */
     Yaf_Loader::import("Smarty/Adapter.php");
     $smarty = new Smarty_Adapter(null, Yaf_Application::app()->getConfig()->smarty);
     $dispatcher->setView($smarty);
 }
开发者ID:gangjun911,项目名称:yaf-examples,代码行数:7,代码来源:Bootstrap.php


示例10: _initConfig

 public function _initConfig()
 {
     //把配置保存起来
     $this->arrConfig = Yaf_Application::app()->getConfig();
     $arrConfig = Yaf_Application::app()->getConfig();
     Yaf_Registry::set('config', $arrConfig);
 }
开发者ID:Wen1750686723,项目名称:yafdemo,代码行数:7,代码来源:Bootstrap.php


示例11: _init

 public function _init(Yaf_Dispatcher $dispatcher)
 {
     // auto start session
     Yaf_Session::getInstance()->start();
     // auto load config data
     $this->config = Yaf_Application::app()->getConfig();
     Yaf_Registry::set('Config', $this->config);
     //auto load redis
     $redis = new Redis();
     $redis->connect($this->config->redis->host, $this->config->redis->port, $this->config->redis->timeout, $this->config->redis->reserved, $this->config->redis->interval);
     Yaf_Registry::set('Redis', $redis);
     //auto load mysql
     Yaf_Registry::set('DbRead', new Db('mysql:host=' . $this->config->mysql->read->host . ';dbname=' . $this->config->mysql->read->dbname . ';charset=' . $this->config->mysql->read->charset . ';port=' . $this->config->mysql->read->port . '', $this->config->mysql->read->username, $this->config->mysql->read->password));
     Yaf_Registry::set('DbWrite', new Db('mysql:host=' . $this->config->mysql->write->host . ';dbname=' . $this->config->mysql->write->dbname . ';charset=' . $this->config->mysql->write->charset . ';port=' . $this->config->mysql->write->port . '', $this->config->mysql->write->username, $this->config->mysql->write->password));
     // auto load model
     Yaf_Registry::set('I18n', new I18nModel($redis, $this->config->application->name, 'cn'));
     Yaf_Registry::set('Cache', new CacheModel($redis, $this->config->application->name));
     // auto load plugin
     $dispatcher->registerPlugin(new GlobalPlugin());
     // auto save request
     $request = $dispatcher->getRequest();
     // auto set ajax is no render
     if ($request->isXmlHttpRequest()) {
         $dispatcher->autoRender(false);
     }
     // auto set http protocol to action except http get protocol
     if (!$request->isGet()) {
         $dispatcher->setDefaultAction($request->getMethod());
     }
 }
开发者ID:a707937337,项目名称:helloword,代码行数:30,代码来源:Bootstrap.php


示例12: errorAction

 function errorAction($exception)
 {
     // fallback views path to global when error occured in modules.
     $config = Yaf_Application::app()->getConfig();
     $this->getView()->setScriptPath($config->application->directory . "/views");
     $this->getView()->e = $exception;
     $this->getView()->e_class = get_class($exception);
     $this->getView()->e_string_trace = $exception->getTraceAsString();
     $params = $this->getRequest()->getParams();
     unset($params['exception']);
     $this->getView()->params = array_merge(array(), $params, $this->getRequest()->getPost(), $this->getRequest()->getQuery());
     switch ($exception->getCode()) {
         case YAF_ERR_AUTOLOAD_FAILED:
         case YAF_ERR_NOTFOUND_MODULE:
         case YAF_ERR_NOTFOUND_CONTROLLER:
         case YAF_ERR_NOTFOUND_ACTION:
             header('HTTP/1.1 404 Not Found');
             break;
         case 401:
             $this->forward('Index', 'application', 'accessDenied');
             header('HTTP/1.1 401 Unauthorized');
             Yaf_Dispatcher::getInstance()->disableView();
             echo $this->render('accessdenied');
             break;
         default:
             //header("HTTP/1.1 500 Internal Server Error");
             core::dump($exception);
             break;
     }
 }
开发者ID:290329416,项目名称:guahao,代码行数:30,代码来源:Error.php


示例13: _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


示例14: connect

 /**
  * Connect to MySQL [Support read/write splitting]
  *
  * @param string => use default DB if parameter is not specified !
  * @return NULL
  */
 private function connect($type = 'WRITE')
 {
     $config = Yaf_Application::app()->getConfig();
     $db = $config['Default'];
     $driver = $config['TYPE'];
     $host = $config[$type . '_HOST'];
     $port = $config[$type . '_PORT'];
     $user = $config[$type . '_USER'];
     $pswd = $config[$type . '_PSWD'];
     if (!$port) {
         $port = 3306;
     }
     $dsn = $driver . ':host=' . $host . ';port=' . $port . ';dbname=' . $db;
     try {
         if (!self::$obj[$type]) {
             self::$conn = self::$obj[$type] = new PDO($dsn, $user, $pswd);
             self::$conn->query('SET NAMES utf8');
             unset($db, $driver, $host, $port, $user, $pswd, $dsn);
         }
     } catch (PDOException $e) {
         if (ENV == 'DEV') {
             Helper::raiseError(debug_backtrace(), $e->getMessage());
         } else {
             file_put_contents($this->logFile, $e->getMessage() . PHP_EOL, FILE_APPEND);
         }
     }
 }
开发者ID:udeth,项目名称:YOF,代码行数:33,代码来源:M_Model.pdo.php


示例15: routerShutdown

 public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     $modules = Yaf_Application::app()->getModules();
     $uri = $request->getRequestUri();
     $uriInfo = explode('/', $uri);
     $module = ucfirst($uriInfo[1]);
     if (!in_array($module, $modules)) {
         $module = 'index';
         // 由于 YAF 源码只不支持大小写混写的控制器和 Action名, 这里来满足
         if ($request->controller) {
             if (strtoupper($request->controller) == strtoupper($uriInfo[1])) {
                 $controller = ucfirst($uriInfo[1]);
                 $request->setControllerName($controller);
             }
         }
         if ($request->action) {
             if (strtoupper($request->action) == strtoupper($uriInfo[2])) {
                 $request->setActionName($uriInfo[2]);
             }
         }
     } else {
         $request->setModuleName($module);
         $request->setControllerName(ucfirst($uriInfo[2]));
         $action = $uriInfo[3];
         if (!$action) {
             $action = 'index';
         }
         $request->setActionName($action);
     }
     //pr($request);
 }
开发者ID:xujunjiepk,项目名称:YOF,代码行数:31,代码来源:Router.php


示例16: __construct

 public function __construct()
 {
     $config = Yaf_Application::app()->getConfig();
     Yaf_Loader::import('L_Wechat');
     $options = array('token' => self::WX_TOKEN, 'appid' => $config['wx_appID'], 'appsecret' => $config['wx_appsecret'], 'access_token' => $config['wx_access_token'], 'expires' => $config['wx_expires']);
     $this->wxSDK = new L_Wechat($options);
 }
开发者ID:GobYang,项目名称:thaidh,代码行数:7,代码来源:Com_Weixin.php


示例17: _initDefaultDbAdapter

 public function _initDefaultDbAdapter()
 {
     //新建对象
     $dbAdapter = new Zend\Db\Adapter\Adapter(Yaf_Application::app()->getConfig()->mysql->write->toArray());
     //设为全局变量
     Yaf_Registry::set("db", $dbAdapter);
 }
开发者ID:nameNotNull,项目名称:Yaf_zendDb,代码行数:7,代码来源:bootstrap.php


示例18: _initConfig

 /**
  * 把配置存到注册表
  */
 function _initConfig()
 {
     Yaf_Registry::set("config", $config = Yaf_Application::app()->getConfig());
     define('PATH_APP', $config->application->directory);
     define('PATH_TPL', PATH_APP . '/views');
     define('USER_IP', Tool_Fnc::realip());
 }
开发者ID:tanqinwang,项目名称:test_own,代码行数:10,代码来源:Bootstrap.php


示例19: _generateShare

 private function _generateShare($url)
 {
     $config = Yaf_Application::app()->getConfig();
     $appID = $config['wx_appID'];
     $appSecret = $config['wx_appSecret'];
     $share['appID'] = $appID;
     $share['timestamp'] = CUR_TIMESTAMP;
     $share['nonceStr'] = 'Wu5WZYThz1wzccnX';
     $share['link'] = $url;
     // 验证 ticket 是否失效
     $m_ticket = $this->load('Ticket');
     $ticket = $m_ticket->SelectOne();
     $gap = CUR_TIMESTAMP - $ticket['addTime'];
     if (!$ticket['ticket'] || $gap > 7200) {
         // Get token
         $token = $this->_getToken($appID, $appSecret);
         // Get ticket
         $ticket = $this->_getTicket($token);
         if ($ticket) {
             $jsapi_ticket = $m['ticket'] = $ticket;
             $m['addTime'] = CUR_TIMESTAMP;
             $where = 1;
             $m_ticket->Delete($where);
             $m_ticket->Insert($m);
         }
     } else {
         $jsapi_ticket = $ticket['ticket'];
     }
     // Get signature
     $string1 = 'jsapi_ticket=' . $jsapi_ticket . '&noncestr=' . $share['nonceStr'];
     $string1 .= '&timestamp=' . $share['timestamp'] . '&url=' . $url;
     $share['signature'] = sha1($string1);
     return $share;
 }
开发者ID:xujunjiepk,项目名称:YOF,代码行数:34,代码来源:Weixin.php


示例20: routerShutdown

 public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
 {
     //pr($request);
     $modules = Yaf_Application::app()->getModules();
     $uri = $request->getRequestUri();
     $uriInfo = explode('/', $uri);
     $module = ucfirst($uriInfo[1]);
     $controller = $uriInfo[2];
     $action = $uriInfo[3];
     if (!in_array($module, $modules)) {
         $module = 'index';
         $controller = $uriInfo[1];
         $action = $uriInfo[2];
     }
     $request->setModuleName(ucfirst($module));
     if (!$controller) {
         $controller = 'index';
     }
     $request->setControllerName(ucfirst($controller));
     if (!$action) {
         $action = 'index';
     }
     $request->setActionName($action);
     //pr($request);
 }
开发者ID:pan269,项目名称:YOF,代码行数:25,代码来源:Router.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Yaf_Dispatcher类代码示例发布时间:2022-05-23
下一篇:
PHP YII类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap