详细说明:
- InitPHP的工具库类文件放置在
initphp/library/文件夹下
- 工具类主要是帮助用户快速开发和一些经常使用的类
如何加载扩展库:
- 工具库的加载主要有两种方式:$this->load('类名称', 'u')和$this->getLibrary('类名称')
- $this->load('类名称', 'u'):框架全局加载API函数,不推荐使用
- $this->getLibrary('类名称'):推荐使用该函数
- InitPHP::getLibrarys('类名称') 静态方式调用
- 类名称都不需要加类名'Init'后缀
class indexController extends Controller {
public $initphp_list = array('test');
public function run() {
$page = $this->getLibrary('pager');
}
public function test() {
echo 'Hello World';
}
/**
* @return testService
*/
private function getTestService() {
return InitPHP::getService('test','test');
}
}
开发扩展库:
- 将您的类放进
initphp/core/util/文件夹下
- 类名和文件名称都需要加后缀'Init'
- 这样就可以直接使用$this->getLibrary()或者InitPHP::getLibrarys()函数来加载了