コード例 #1
0
ファイル: Ctx.php プロジェクト: hihus/Ctx
<?php

//---测试demo--
ini_set('display_errors', 1);
//@todo 后边也有,这个要去掉
ini_set('error_reporting', E_ALL);
//@todo 后边也有,这个要去掉
define('BRR', '<br />' . "\n");
echo '--通用服务框架测试--start--' . BRR;
try {
    $rootDir = dirname(__FILE__);
    $configPath = $rootDir . '/security/config';
    $ctx = Ctx::getInstance($configPath);
    $ctx->user->getUserInfo(123123);
    $ctx->user->getUserInfo(22222);
} catch (CtxException $e) {
    echo '---框架错误:' . $e->getMessage() . BRR;
} catch (Exception $e) {
    echo $e->getMessage() . BRR;
}
exit('--end--');
/**
* 通用context对象
* @example 
   require_once(dirname(Tree6P_PATH) . DS . 'codebase' . DS . 'Ctx.php');
   try {
       $rootDir = dirname(__FILE__);
       $configPath = $rootDir . '/security/config';
       $ctx = Ctx::getInstance($configPath);
       $ctx->user->getUserInfo(123123);
       $ctx->user->getUserInfo(22222);
コード例 #2
0
ファイル: Ctx.php プロジェクト: ijidan/Ctx
<?php

//---测试demo--
ini_set('display_errors', 1);
//@todo 后边也有,这个要去掉
ini_set('error_reporting', E_ALL);
//@todo 后边也有,这个要去掉
define('BRR', '<br />' . "\n");
echo '--通用服务框架测试--start--' . BRR;
try {
    $rootDir = dirname(__FILE__);
    $configDir = $rootDir . '/security';
    $ctx = Ctx::getInstance($configDir);
    echo $ctx->user->test();
    echo '--单例对象的测试--end--' . BRR . BRR;
    //测试非单例的方式调用,方便复用对象
    echo $ctx->user->getUser(123123)->getInfo();
    echo $ctx->user->getUser(22222)->getInfo();
    echo $ctx->user->getUser(123123)->getInfo();
    echo $ctx->user->getUser(22222)->getInfo();
} catch (CtxException $e) {
    echo '---框架错误:' . $e->getMessage() . BRR;
} catch (Exception $e) {
    echo $e->getMessage() . BRR;
}
exit('--end--');
/**
* 通用context对象
* 类属性命名规则:ctx 开头的可以读,_ctx 开头的私有的不可读
* @example 
<pre>