本文整理匯總了PHP中Bootstrap::config方法的典型用法代碼示例。如果您正苦於以下問題:PHP Bootstrap::config方法的具體用法?PHP Bootstrap::config怎麽用?PHP Bootstrap::config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::config方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
/**
* Inicia el bootstrap
*/
public static function init()
{
//FIXME dejar esto configurable
date_default_timezone_set("America/Mexico_City");
self::$config = (include 'config/application.config.php');
self::$smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array();
self::$listeners = isset($configuration['listeners']) ? $configuration['listeners'] : array();
}
示例2: meta
/**
* @return MetaAbstract
* */
public function meta()
{
$dsName = $this->_bootstrap->config('app.persist.default');
$config = $this->_bootstrap->config('app.persist')->toArray();
$pConfig = PersistConfig::factory($dsName, $config);
$persist = \br\gov\sial\core\persist\database\Connect::factory($pConfig);
return MetaAbstract::factory($persist);
}
示例3: reload_all_libraries
/**
* 重新加載類庫
*
*/
protected static function reload_all_libraries()
{
# 加載類庫
$lib_config = self::$core_config['libraries'];
# 重置
self::$include_path['library'] = array();
foreach (array('autoload', 'cli', 'admin', 'debug', 'rest') as $type) {
if (!isset($lib_config[$type]) || !$lib_config[$type]) {
continue;
}
if ($type == 'cli') {
if (!IS_DEBUG) {
continue;
}
} else {
if ($type == 'admin') {
if (!IS_ADMIN_MODE) {
continue;
}
} else {
if ($type == 'rest') {
if (!IS_REST_MODE) {
continue;
}
} else {
if ($type == 'debug') {
if (!IS_DEBUG) {
continue;
}
}
}
}
}
$libs = array_reverse((array) $lib_config[$type]);
foreach ($libs as $lib) {
self::_add_include_path_lib($lib);
}
}
# 處理 library 的config
$config_files = array();
self::get_config_file_by_path($config_files, self::$include_path['project'], true);
self::get_config_file_by_path($config_files, self::$include_path['team-library'], true);
self::get_config_file_by_path($config_files, self::$include_path['library'], false);
self::get_config_file_by_path($config_files, self::$include_path['core'], false);
if ($config_files) {
# 反向排序,從最後一個開始導入
$config_files = array_reverse($config_files);
# 導入config
self::$config = self::$core_config;
# 移除特殊的key
unset(self::$config['core']);
unset(self::$config['projects']);
# 載入config
__include_config_file(self::$config, $config_files);
}
}
示例4: setup
/**
* 係統初始化
*
* @param boolean $auto_execute 是否自動運行
*/
public static function setup($auto_execute = true)
{
static $run = null;
if (!$run) {
$run = true;
# 注冊自動加載類
spl_autoload_register(array('Bootstrap', 'auto_load'));
# 讀取配置
if (!is_file(DIR_SYSTEM . 'config' . EXT)) {
self::show_error('Please rename the file config.new.php to config.php');
}
$include_config_file = function (&$config, $file) {
include $file;
};
self::$config = array('core' => array());
# 讀取主配置
$include_config_file(self::$config['core'], DIR_SYSTEM . 'config' . EXT);
# 讀Debug配置
if (isset(self::$config['core']['debug_config']) && self::$config['core']['debug_config'] && is_file(DIR_SYSTEM . 'debug.config' . EXT)) {
$include_config_file(self::$config['core'], DIR_SYSTEM . 'debug.config' . EXT);
}
# DEBUG配置
if (isset(self::$config['core']['local_debug_cfg']) && self::$config['core']['local_debug_cfg']) {
if (function_exists('get_cfg_var')) {
$open_debug = get_cfg_var(self::$config['core']['local_debug_cfg']) ? 1 : 0;
} else {
$open_debug = 0;
}
} else {
$open_debug = 0;
}
/**
* 判斷是否開啟了在線調試
*
* @return boolean
*/
$is_online_debug = function () {
if (IS_SYSTEM_MODE) {
if (isset($_SERVER['HTTP_X_MYQEE_SYSTEM_DEBUG']) && $_SERVER['HTTP_X_MYQEE_SYSTEM_DEBUG'] == '1') {
return true;
} else {
return false;
}
}
if (!isset($_COOKIE['_debug_open'])) {
return false;
}
if (!isset(Bootstrap::$config['core']['debug_open_password'])) {
return false;
}
if (!is_array(Bootstrap::$config['core']['debug_open_password'])) {
return false;
}
foreach (Bootstrap::$config['core']['debug_open_password'] as $user => $pass) {
if ($_COOKIE['_debug_open'] == Bootstrap::get_debug_hash($user, $pass)) {
return true;
}
}
return false;
};
if ($is_online_debug()) {
$open_debug == 1 << 1 | $open_debug;
}
unset($is_online_debug);
/**
* 是否開啟DEBUG模式
*
* if (IS_DEBUG>>1)
* {
* //開啟了在線調試
* }
*
* if (IS_DEBUG & 1)
* {
* //本地調試打開
* }
*
* if (IS_DEBUG)
* {
* // 開啟了調試
* }
*
* @var int
*/
define('IS_DEBUG', $open_debug);
# 請求模式
$request_mode = '';
if (IS_CLI) {
if (!isset($_SERVER["argv"])) {
exit('Err Argv');
}
$argv = $_SERVER["argv"];
//$argv[0]為文件名
if (isset($argv[1]) && $argv[1] && isset(self::$config['core']['projects'][$argv[1]])) {
self::$project = $argv[1];
//.........這裏部分代碼省略.........
示例5: set_project
/**
* 設置項目
* 可重新設置新項目已實現程序內項目切換,但需謹慎使用
* @param string $project
*/
public static function set_project($project)
{
if (self::$project == $project) {
return true;
}
static $core_config = null;
if (null === $core_config) {
# 記錄原始Core配置
$core_config = self::$config['core'];
}
if (!isset($core_config['projects'][$project])) {
self::_throw_sys_error_msg(__('not found the project: :project.', array(':project' => $project)));
}
if (!$core_config['projects'][$project]['isuse']) {
self::_throw_sys_error_msg(__('the project: :project is not open.', array(':project' => '$project')));
}
# 獲取core裏項目配置
$project_config = $core_config['projects'][$project];
# 項目路徑
$project_dir = realpath(DIR_PROJECT . $project_config['dir']);
if (!$project_dir || !is_dir($project_dir)) {
self::_throw_sys_error_msg(__('the project dir :dir is not exist.', array(':dir' => $project_config['dir'])));
}
$project_dir .= DS;
self::$project_dir = $project_dir;
# 記錄所有項目設置,當切換回項目時,使用此設置還原
static $all_prjects_setting = array();
if (self::$project) {
# 記錄上一個項目設置
$all_prjects_setting[self::$project] = array('config' => self::$config, 'project_config' => self::$project_config, 'include_path' => self::$include_path, 'file_list' => self::$file_list);
}
# 設為當前項目
self::$project = $project;
# 記錄debug信息
if (class_exists('Core', false)) {
Core::debug()->info('程序已切換到了新項目:' . $project);
}
if (isset($all_prjects_setting[$project])) {
# 還原配置
self::$config = $all_prjects_setting[$project]['config'];
self::$project_config = $all_prjects_setting[$project]['project_config'];
self::$include_path = $all_prjects_setting[$project]['include_path'];
self::$file_list = $all_prjects_setting[$project]['file_list'];
} else {
# 合並配置
$config = $core_config['projects'][$project] + self::$config['core'];
# 讀取項目配置
if (is_file($project_dir . 'config' . EXT)) {
self::_include_config_file($config, $project_dir . 'config' . EXT);
}
# 讀取DEBUG配置
if (isset(self::$config['core']['debug_config']) && self::$config['core']['debug_config'] && is_file($project_dir . 'debug.config' . EXT)) {
self::_include_config_file($config, $project_dir . 'debug.config' . EXT);
}
# 清理項目配置
self::$project_config = $config;
self::$config = array('core' => &self::$project_config);
unset($config);
# Builder構建,處理 self::$file_list
if (self::$project_config['use_bulider'] === 'auto') {
if (IS_DEBUG) {
$usebulider = false;
} else {
$usebulider = true;
}
} else {
$usebulider = (bool) self::$project_config['use_bulider'];
}
$project_filelist = DIR_BULIDER . self::$project . DS . 'project_all_files_list' . EXT;
if (true === $usebulider && !IS_CLI && is_file($project_filelist)) {
# 讀取文件列表
self::_include_config_file(self::$file_list, $project_filelist);
}
# 設置包含目錄
self::$include_path = self::get_project_include_path($project);
}
if (isset(self::$project_config['error_reporting'])) {
error_reporting(self::$project_config['error_reporting']);
}
# 時區設置
if (isset(self::$project_config['timezone'])) {
date_default_timezone_set(self::$project_config['timezone']);
}
if (class_exists('Core', false)) {
# 輸出調試信息
if (IS_DEBUG) {
Core::debug()->group('當前加載目錄');
foreach (self::$include_path as $value) {
Core::debug()->log(Core::debug_path($value));
}
Core::debug()->groupEnd();
}
Core::ini_library();
}
}