Bootstrap
API - Bootstrap
- Bootstrap::$include_path - 包含目录
- Bootstrap::$base_url - 当前URL的根路径
- Bootstrap::$path_info - 当前URL的PATH_INFO
- Bootstrap::$project - 当前项目
- Bootstrap::$project_dir - 当前项目目录
- Bootstrap::$project_url - 当前项目的URL
- Bootstrap::$file_list - 系统文件列表
- Bootstrap::setup - 系统初始化
- Bootstrap::auto_load - 自动加载类
- Bootstrap::include_path - 获取包含目录,返回一个一维的数组
- Bootstrap::find_file - 查找文件
- Bootstrap::import_library - 导入指定类库
- Bootstrap::get_debug_hash - 根据用户名和密码获取一个hash
- Bootstrap::protocol - 返回协议类型
系统初始化
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
$auto_execute |
boolean |
是否自动运行控制器 | bool true |
自动加载类
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
$class_name |
string |
$class_name |
boolean 获取包含目录,返回一个一维的数组
Bootstrap::$include_path 为一个二维数组array 查找文件
// 查找类文件路径
$file = Bootstrap::find_file('classes', 'Database');
// 查找一个视图文件
$file = Bootstrap::find_file('views', 'test');
// 查找一个自定义文件,注意第3个参数设置空表示后缀在文件名中
$file = Bootstrap::find_file('assets', 'test.css', '');
// 等价于
$file = Bootstrap::find_file('assets', 'test', '.css');
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
$dir |
string |
目录 | |
$file |
string |
文件 | |
$ext |
string |
后缀 例如:.html,不指定(null)的话则自动设置后缀 | null |
$auto_require |
boolean |
是否自动加载上来,对config,i18n无效 | bool false |
string 导入指定类库 支持多个,当一次导入多个时,从数组最后一个开始导入
导入的格式必须是类似 com.a.b 的形式,否则会抛出异常,例如: com.myqee.test
Bootstrap::import_library('com.myqee.test');
Bootstrap::import_library(array('com.myqee.test','com.myqee.cms'));
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
$library_name |
string|array |
指定类库 支持多个 |
num 返回新加载的类库总数加入include_path类库
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
$lib |
string |
$lib |
array `array($ns, $dir, $is_already_loaded)`根据用户名和密码获取一个hash
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
$username |
string |
$username | |
$password |
string |
$password |
string 返回协议类型
当在命令行里执行,则返回null
string `null` | `http://` | `https://`重新加载类库
根据URL初始化
抛出系统启动时错误信息
| 参数 | 类型 | 描述 | 默认值 |
|---|---|---|---|
$msg |
string |
$msg |