本文整理汇总了PHP中Bootstrap::include_path方法的典型用法代码示例。如果您正苦于以下问题:PHP Bootstrap::include_path方法的具体用法?PHP Bootstrap::include_path怎么用?PHP Bootstrap::include_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::include_path方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup_by_url
//.........这里部分代码省略.........
} else {
# /开头的后台URL
$admin_url[] = $admin_url;
}
}
}
if ($item['url']) {
if (!is_array($item['url'])) {
$item['url'] = array($item['url']);
}
foreach ($item['url'] as $url) {
if (($path_info = $get_path_info($url)) != false) {
self::$project = $project;
self::$path_info = $path_info;
self::$base_url = $url;
if ($admin_url) {
foreach ($admin_url as $url2) {
# 处理后台URL不是 http:// 或 https:// 开头的形式
if (($path_info_admin = $get_path_info($url2)) != false) {
self::$path_info = $path_info_admin;
self::$base_url .= ltrim($url2, '/');
$request_mode = 'admin';
break 3;
}
}
}
break 2;
}
}
}
}
}
if (self::$project) {
$project_dir = DIR_PROJECT . self::$project . DS;
if (!is_dir($project_dir)) {
self::show_error('not found the project: :project', array(':project' => self::$project));
}
# 根据URL寻找到了项目
self::$include_path = array_merge(array('\\project\\' . self::$project . '\\' => $project_dir), self::$include_path);
} else {
if (isset(self::$config['core']['url']['admin']) && self::$config['core']['url']['admin'] && ($path_info = $get_path_info(self::$config['core']['url']['admin'])) != false) {
self::$path_info = $path_info;
self::$base_url = self::$config['core']['url']['admin'];
$request_mode = 'admin';
} else {
if (isset(self::$config['core']['apps_url']) && is_array(self::$config['core']['apps_url']) && self::$config['core']['apps_url']) {
foreach (self::$config['core']['apps_url'] as $app => $urls) {
if (!$urls) {
continue;
}
if (!preg_match('#^[a-z0-9_]+//[a-z0-9]+$#i', $app)) {
continue;
}
if (!is_array($urls)) {
$urls = array($urls);
}
foreach ($urls as $url) {
if (($path_info = $get_path_info($url)) != false) {
self::$app = $app;
self::$path_info = $path_info;
self::$base_url = $url;
break 2;
}
}
}
}
if (null === self::$app) {
# 没有相关应用
if (isset(self::$config['core']['url']['apps']) && self::$config['core']['url']['apps']) {
if (($path_info = $get_path_info(self::$config['core']['url']['apps'])) != false) {
# 匹配到应用默认目录
$path_info = trim($path_info, '/');
self::$app = true;
if ($path_info) {
$path_info_arr = explode('/', $path_info);
if (count($path_info_arr) >= 2) {
$app = array_shift($path_info_arr) . '/' . array_shift($path_info_arr);
if (preg_match('#^[a-z0-9_]+//[a-z0-9]+$#i', $app)) {
$path_info = '/' . implode('/', $path_info_arr);
self::$app = $app;
}
}
}
self::$path_info = $path_info;
self::$base_url = self::$config['core']['url']['apps'];
$request_mode = 'app';
}
}
}
if (self::$app && true !== self::$app) {
# 已获取到APP
$app_dir = DIR_APPS . self::$app . DS;
if (!is_dir($app_dir)) {
self::show_error('can not found the app: :app', array(':app' => self::$app));
}
$request_mode = 'app';
}
}
}
}
示例2: find_lang_files
/**
* 获取语言包文件和修改时间
*
* @return array array('files'=>array(), 'last_mtime'=>0);
*/
protected static function find_lang_files()
{
if (self::$core_initialized) {
$accept_language = I18n::accept_language();
$include_path = Core::include_path();
} else {
$accept_language = self::accept_language();
$include_path = Bootstrap::include_path();
}
$accept_language = array_reverse($accept_language);
$include_path = array_reverse($include_path);
$found = array('files' => array(), 'last_mtime' => 0);
foreach ($include_path as $path) {
foreach ($accept_language as $lang) {
$file = $path . 'i18n' . DS . $lang . '.lang';
if (is_file($file)) {
$found['files'][] = $file;
$found['last_mtime'] = max($found['last_mtime'], filemtime($file));
}
}
}
return $found;
}
示例3: 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();
}
}