当前位置: 首页>>代码示例>>PHP>>正文


PHP application::settings方法代码示例

本文整理汇总了PHP中application::settings方法的典型用法代码示例。如果您正苦于以下问题:PHP application::settings方法的具体用法?PHP application::settings怎么用?PHP application::settings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在application的用法示例。


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

示例1: build

 /**
  * URL组装,兼容各种路由模式
  *
  * @param	string $url	如:admin://system/msg/send/username/args2 或者 system/msg/send/username/args2
  * @param	array $params 参数
  * @param	string $fragment 锚点名称或者框架名称
  * @return	string 完整的url
  */
 public static function build($uri, $params = array(), $fragment = '')
 {
     $uri = trim($uri, '/');
     //去掉开头结尾的 / 符号,或者去掉分隔符
     if (strpos($uri, '://') === false) {
         $uri = router::application() . '://' . $uri;
     }
     $uris = parse_url($uri);
     $paths = explode('/', trim($uris['path'], '/'));
     $urls = array();
     $urls['base'] = $uris['scheme'] == router::application() ? url::base() : application::settings($urls['scheme'], 'base');
     $urls['module'] = $uris['host'];
     $urls['controller'] = $paths[0];
     $urls['action'] = $paths[1];
     //zotop::dump($urls);
     if (zotop::config('zotop.url.model') == 0) {
     } else {
         $url = $urls['base'];
         if (zotop::config('zotop.url.model') == 2) {
             $url = $url . '?zotop=';
             //开启兼容模式
         }
         $url = $url . '/' . $urls['module'] . '/' . $urls['controller'] . '/' . $urls['action'];
         if (!empty($params)) {
             foreach ($params as $key => $value) {
                 $url .= '/' . $value;
             }
         }
     }
     if (!empty($fragment)) {
         $url .= '#' . $fragment;
     }
     return url::clean($url);
 }
开发者ID:dalinhuang,项目名称:zotop,代码行数:42,代码来源:url.php

示例2: run

 /**
  * Run application
  * 
  * @param array $options
  *		string application_name
  *		string application_path
  *		string ini_folder
  *		boolean __run_only_bootstrap
  * @throws Exception
  */
 public static function run($options = [])
 {
     // fixing location paths
     $application_path = isset($options['application_path']) ? rtrim($options['application_path'], '/') . '/' : '../application/';
     $application_name = isset($options['application_name']) ? $options['application_name'] : 'default';
     $ini_folder = isset($options['ini_folder']) ? rtrim($options['ini_folder'], '/') . '/' : $application_path . 'config/';
     // working directory is location of the application
     chdir($application_path);
     $application_path_full = getcwd();
     // setting include_path
     $paths = [];
     $paths[] = $application_path_full;
     $paths[] = __DIR__;
     $paths[] = str_replace('/numbers/framework', '', __DIR__);
     set_include_path(implode(PATH_SEPARATOR, $paths));
     // support functions
     require "functions.php";
     // load ini settings
     self::$settings = system_config::load($ini_folder);
     // special handling of media files for development, so there's no need to redeploy application
     if (self::$settings['environment'] == 'development' && isset($_SERVER['REQUEST_URI'])) {
         system_media::serve_media_if_exists($_SERVER['REQUEST_URI'], $application_path);
     }
     // we need to solve chicken and egg problem so we load cache first and then run application
     //cache::create('php', array('type'=>'php', 'dir'=>'../application/cache'));
     // setting variables
     if (!isset(self::$settings['application']) || !is_array(self::$settings['application'])) {
         self::$settings['application'] = [];
     }
     self::$settings['application']['name'] = $application_name;
     self::$settings['application']['path'] = $application_path;
     self::$settings['application']['path_full'] = $application_path_full . '/';
     self::$settings['application']['loaded_classes'] = [];
     // class paths
     self::$settings['layout'] = [];
     // layout settings
     // flags
     self::$settings['flag'] = isset(self::$settings['flag']) && is_array(self::$settings['flag']) ? self::$settings['flag'] : [];
     self::$settings['flag']['global']['__run_only_bootstrap'] = !empty($options['__run_only_bootstrap']);
     // magic variables processed here
     self::$settings['flag']['global']['__content_type'] = 'text/html';
     self::process_magic_variables();
     // processing php settings
     if (isset(self::$settings['php'])) {
         foreach (self::$settings['php'] as $k => $v) {
             if (is_array($v)) {
                 foreach ($v as $k2 => $v2) {
                     if (is_numeric($v2)) {
                         $v2 = $v2 * 1;
                     }
                     ini_set($k . '.' . $k2, $v2);
                 }
             } else {
                 if (is_numeric($v)) {
                     $v = $v * 1;
                 }
                 ini_set($k, $v);
             }
         }
     }
     // Destructor
     register_shutdown_function(array('bootstrap', 'destroy'));
     // error handler first
     error_base::init();
     // debug after error handler
     debug::init(self::get('debug'));
     // Bootstrap Class
     $bootstrap = new bootstrap();
     $bootstrap_methods = get_class_methods($bootstrap);
     foreach ($bootstrap_methods as $method) {
         if (strpos($method, 'init') === 0) {
             call_user_func(array($bootstrap, $method), $options);
         }
     }
     // if we are calling application from the command line
     if (!empty($options['__run_only_bootstrap'])) {
         // dispatch before, in case if we open database connections in there
         if (!empty(self::$settings['application']['dispatch']['before_controller'])) {
             call_user_func(self::$settings['application']['dispatch']['before_controller']);
         }
         return;
     }
     // processing mvc settings
     self::set_mvc();
     // check if controller exists
     if (!file_exists(self::$settings['mvc']['controller_file'])) {
         throw new Exception('Resource not found!', -1);
     }
     // initialize the controller
     $controller_class = self::$settings['mvc']['controller_class'];
//.........这里部分代码省略.........
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:101,代码来源:application.php


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