一、目錄結構
1、入口文件 —— index.php
使用conf中的配置文件application.ini(取目錄/application)
調用/application/Bootstrap.php,把這個項目跑起來
<?php
define('APPLICATION_PATH', dirname(__FILE__));
define('APP_PATH', dirname(__FILE__) . '/');
define('FILE_UPLOAD_PATH', dirname(__FILE__) . '/static/uploadDir');
$application = new Yaf_Application( APPLICATION_PATH . "/conf/application.ini");
$application->bootstrap()->run();
?>
2、開發入口 —— Bootstrap.php
很多基礎功能都是在這裏先註冊的
class Bootstrap extends Yaf_Bootstrap_Abstract{
public function _initConfig() {
//把配置保存起來
$arrConfig = Yaf_Application::app()->getConfig();
Yaf_Registry::set('config', $arrConfig);
}
public function _initPlugin(Yaf_Dispatcher $dispatcher) {
//註冊一個插件
$objSamplePlugin = new PluginMain();
$dispatcher->registerPlugin($objSamplePlugin);
}
public function _initRoute(Yaf_Dispatcher $dispatcher) {
//在這裏註冊自己的路由協議,默認使用簡單路由
/* $router = Yaf_Dispatcher::getInstance()->getRouter(); */
/* $router->addConfig(Yaf_Registry::get("config")->routes); */
}
public function _initView(Yaf_Dispatcher $dispatcher){
//在這裏註冊自己的view控制器,例如smarty,firekylin
}
}
3、流程
1)index.php 裏 加載conf中的文件
2)調用Bootstrap.php
3)根據請求裏的controller和action的定義找到對應的controller
4、yaf的路由
rewrite規則
參考:
https://www.cnblogs.com/lzzxm/articles/12537379.html
https://zhuanlan.zhihu.com/p/341479817