示例#1
0
 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');
 }
示例#2
0
文件: Admin.php 项目: ngchie/system
 /**
  * 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');
 }
示例#3
0
文件: Init.php 项目: fanscout/omz
 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;
 }
示例#4
0
文件: Init.php 项目: kaka987/YoungYaf
 /**
  * 初始化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');
 }
示例#5
0
 /**
  * 
  * @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;
 }
示例#6
0
文件: Api.php 项目: ngchie/system
 /**
  * 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();
 }
示例#7
0
 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'));
 }
示例#8
0
 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);
 }
示例#9
0
 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);
 }
示例#10
0
 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;
 }
示例#11
0
<?php

/**
 * Yaf client command
 *
 * @author      Xuexb<*****@*****.**>
 * @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);
//}
示例#12
0
 /**
  * 路由开始事件
  *
  * @author         mrmsl <*****@*****.**>
  * @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();
 }
示例#13
0
 /**
  * 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');
 }
示例#14
0
 /**
  * @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());
     }
 }
示例#15
0
 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();
 }
示例#16
0
 public function _initLoader(Yaf_Dispatcher $dispatcher)
 {
     Yaf_Loader::getInstance()->registerLocalNameSpace(array("System"));
     Yaf_Loader::getInstance()->import($this->_config->application->directory . '/widgets/Index.php');
     Yaf_Loader::import($this->_config->application->directory . "/tools/xapian/xapian.php");
 }
示例#17
0
 /**
  * 注册本地类名前缀, 这部分类名将会在本地类库查找 
  * @param Yaf_Dispatcher $dispatcher
  */
 public function _initLoader(Yaf_Dispatcher $dispatcher)
 {
     Yaf_Loader::getInstance()->registerLocalNameSpace(array('Api', 'Cache', 'Comm', 'Data', 'Entity', 'Model'));
 }
示例#18
0
 public function _initRegisterLocalNamespace()
 {
     Yaf_Loader::getInstance()->registerLocalNamespace(array('Dao', 'Sys', 'User', 'View', 'Export', 'Mail'));
     //add by zhangy@20140604
 }
示例#19
0
 public function _initLocalName()
 {
     Yaf_Loader::getInstance()->registerLocalNamespace(array('Smarty'));
 }
示例#20
0
 /**
  * Method  _initLocalNamespace
  * @desc   ......
  *
  * @author WenJun <*****@*****.**>
  *
  * @return void
  */
 public function _initLocalNamespace()
 {
     $aNamespace = array('Base');
     Yaf_Loader::getInstance()->registerLocalNamespace($aNamespace);
 }
示例#21
0
 public function _initLoader(Yaf_Dispatcher $dispatcher)
 {
     Yaf_Loader::getInstance()->registerLocalNamespace('Common');
 }
示例#22
0
文件: index.php 项目: krisrita/udo
<?php

//echo md5('0|paper/list|howdo'); exit;
if (phpversion() >= "5.3") {
    $root = dirname(__DIR__);
} else {
    $root = dirname(dirname(__FILE__));
}
define("APP_PATH", realpath(dirname(__FILE__) . '/../'));
ini_set('yaf.library', APP_PATH . '/library');
define('SMARTY_SPL_AUTOLOAD', 1);
include APP_PATH . "/library/Smarty/Smarty.class.php";
include APP_PATH . "/vendor/autoload.php";
/*$log = $_SERVER["REMOTE_ADDR"] . "\t" . date("Y-m-d H:i:s") . "\t" ;
$log .= $_SERVER["SCRIPT_NAME"] . "\t";
$log .= preg_replace(array("/\n/", "/\s+/"), ' ', print_r($_REQUEST, true)) . "\t";
$log .= preg_replace(array("/\n/", "/\s+/"), ' ', print_r($_COOKIE, true)) . "\n";
error_log($log, 3, "/data/logs/request" . date("Ymd") . ".log");
*/
$loader = Yaf_Loader::getInstance(APP_PATH . '/library/');
$app = new Yaf_Application(APP_PATH . "/conf/application.ini");
$app->bootstrap();
$app->run();
示例#23
0
 public function _initNameSpace()
 {
     Yaf_Loader::getInstance(APP_PATH . '/application/')->registerLocalNamespace('models');
 }
示例#24
0
 public function _initNamespaces()
 {
     Yaf_Loader::getInstance()->registerLocalNameSpace(array("Zend"));
 }
示例#25
0
文件: Base.php 项目: ngchie/system
 /**
  * Loose coupling of objects in the system
  *
  * @return mixed the bridge class
  */
 public static function getInstance()
 {
     $args = func_get_args();
     $stamp = md5(serialize($args));
     if (isset(self::$instance[$stamp])) {
         return self::$instance[$stamp];
     }
     if (isset($args['type'])) {
         $type = $args['type'];
         $args = array();
         Billrun_Factory::log()->log('Depratected approach of Billrun_Base::getInstance: ' . $type, Zend_Log::INFO);
     } else {
         $type = $args[0]['type'];
         unset($args[0]['type']);
         $args = $args[0];
     }
     $config_type = Yaf_Application::app()->getConfig()->{$type};
     $called_class = get_called_class();
     if ($called_class && Billrun_Factory::config()->getConfigValue($called_class)) {
         $args = array_merge(Billrun_Factory::config()->getConfigValue($called_class)->toArray(), $args);
     }
     $class_type = $type;
     if ($config_type) {
         $args = array_merge($config_type->toArray(), $args);
         if (isset($config_type->{$called_class::$type}) && isset($config_type->{$called_class::$type}->type)) {
             $class_type = $config_type[$called_class::$type]['type'];
             $args['type'] = $type;
         }
     }
     $class = $called_class . '_' . ucfirst($class_type);
     if (!@class_exists($class, true)) {
         // try to search in external sources (application/helpers)
         $external_class = str_replace('Billrun_', '', $class);
         if (($pos = strpos($external_class, "_")) !== FALSE) {
             $namespace = substr($external_class, 0, $pos);
             Yaf_Loader::getInstance(APPLICATION_PATH . '/application/helpers')->registerLocalNamespace($namespace);
         }
         if (!@class_exists($external_class, true)) {
             Billrun_Factory::log("Can't find class: " . $class, Zend_Log::EMERG);
             return false;
         }
         $class = $external_class;
     }
     self::$instance[$stamp] = new $class($args);
     return self::$instance[$stamp];
 }
示例#26
0
<?php

/*
 * Excel 实用类
 * @param excelObj PHPExcel对象
 * @param $file_Name 下载文件名设定
 */
//XXX 防止多次加载
if (!defined('HELPER_EXCEL_FILE')) {
    define('HELPER_EXCEL_FILE', 1);
    //重定向YAF的autoload文件路径配置
    $loader = Yaf_Loader::getInstance(dirname(__FILE__) . '/../thirdlib/excel/');
    $loader->registerLocalNamespace("PHPExcel");
    $loader->autoload("PHPExcel");
    //家在核心文件
    //XXX 使用已有的常量路径进行定义
    require_once ROOT_COREAPPLIB . '/thirdlib/excel/PHPExcel.php';
    require_once ROOT_COREAPPLIB . '/thirdlib/excel/Excel5.php';
}
class Helper_Excel
{
    private $excelObj;
    private $excelReaderObj;
    private $file_Name = '';
    public function __construct()
    {
        //建立PHPExcel实例化
        $this->excelObj = new PHPExcel();
    }
    /*
     * @params string $fileName 字符串
示例#27
0
 /**
  * * 初始化APP的数据
  * * 
  * * @param string $app 启用的app的名称,如:test
  * */
 private static function initApp($app)
 {
     if (empty($app)) {
         exit('App must not be empty');
     }
     define('PDP_APP', $app);
     define('PDP_APP_ROOT', DIR_APP . '/' . PDP_APP);
     define('PDP_APP_LIB', PDP_APP_ROOT . '/library');
     define('PDP_APP_VIEW', PDP_APP_ROOT . '/views');
     define('PDP_APP_DATA', PDP_ROOT . '/data/app/' . PDP_APP);
     //声明loader
     Yaf_Loader::getInstance(PDP_APP_LIB, PDP_ROOT_PHPLIB);
     Arch_Env::set(Arch_Env::NS, PDP_APP);
     $config = array("application" => array("directory" => PDP_APP_ROOT, 'library' => PDP_APP_LIB, 'baseUri' => '/' . $app));
     self::$app = new Yaf_Application($config);
     //增加日志初始化
     Core_Conf::init(array('path' => PDP_DIR_CONF . '/'));
     //增加日志的初始化
     Core_Log::init(array('path' => PDP_DIR_LOG . '/' . PDP_APP . '/', 'file' => PDP_APP . '.log'));
 }
示例#28
0
 /**
  * [加载 命名空间 加载local library components文件]
  * @return [type] [description]
  */
 public function _initRegisterLocalNamespace()
 {
     $loader = Yaf_Loader::getInstance();
     $loader->registerLocalNamespace(array('Controller', 'Helper'));
 }
示例#29
0
 * PDP的预载入文件
 *
 * PHP每次执行的时候都需要先载入这个文件
 *
 * 本文件被放置在目录:
 * 	   $pdpdir/phplib/prepend.php
 * 
 * 1. 定义基础变量
 * 2. 注册全局类库路径
 * 
 * @author 胡峰 <*****@*****.**>
 * @version 1.0.0
 * @package core
 * @copyright 2014-2015 yunsupport.com
 */
//定义基础变量
define('ROOT', realpath(dirname(__FILE__) . '/../'));
define('DIR_DAT', ROOT . '/data/');
define('DIR_LOG', ROOT . '/log/');
define('DIR_CONF', ROOT . '/conf/');
define('PHPLIB', ROOT . '/phplib/');
define('DIR_APP', ROOT . '/app/');
define('PDP_VERSION', '1.0.0');
define('PDP_ROOT', ROOT);
define('PDP_DIR_APP', DIR_APP);
define('PDP_DIR_DAT', DIR_DAT);
define('PDP_DIR_LOG', DIR_LOG);
define('PDP_DIR_CONF', DIR_CONF);
define('PDP_ROOT_PHPLIB', PHPLIB);
Yaf_Loader::getInstance(NULL, PDP_ROOT_PHPLIB);
示例#30
0
 private function getController($appDir, $module, $controller)
 {
     $controllerDir = '';
     if ($this->_default_module == $module) {
         $controllerDir = $appDir . DIRECTORY_SEPARATOR . Yaf_Loader::YAF_CONTROLLER_DIRECTORY_NAME;
     } else {
         $controllerDir = $appDir . DIRECTORY_SEPARATOR . Yaf_Loader::YAF_MODULE_DIRECTORY_NAME . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . Yaf_Loader::YAF_CONTROLLER_DIRECTORY_NAME;
     }
     $nameSeparator = Yaf_G::iniGet('yaf.name_separator');
     if (Yaf_G::iniGet('yaf.name_suffix') == true) {
         $classname = $controller . $nameSeparator . 'Controller';
     } else {
         $classname = 'Controller' . $nameSeparator . $controller;
     }
     if (!@class_exists($classname, false)) {
         if (!Yaf_Loader::getInstance()->internal_autoload($controller, $controllerDir)) {
             throw new Yaf_Exception_LoadFailed_Controller('Could not find controller script ' . $controllerDir . DIRECTORY_SEPARATOR . $controller . '.' . Yaf_G::get('ext'));
         }
     }
     if (!class_exists($classname, false)) {
         throw new Yaf_Exception_LoadFailed('Could not find class ' . $classname . ' in controller script ' . $controllerDir);
     }
     return $classname;
 }