1.入口文件。index.php站点全局配置文件。configs/Website.phparray(*'routingalias'=>'controller@method'*)*)*/returnarray('Home'=>array('index-index'=>'IndexController@index','index/test'=>'IndexController@test',),'Admin'=>array('login'=>'IndexController@login'),);四、框架启动文件。frame/App.phpctrl;$action=$route->action;$namespace=$route->namespace;if($namespace){$ctrlFile=CTRL.'/'.$namespace.'/'.$ctrl.'.php';$ctrlObj=CTRLNAMESPACE.$namespace.'\\'.$ctrl;}else{$ctrlFile=CTRL.'/'.$ctrl.'Controller.php';$ctrlObj=CTRLNAMESPACE.$ctrl.'控制器';}if(is_file($ctrlFile)){require_once($ctrlFile);$obj=new$ctrlObj;如果(method_exists($obj,$action)){$obj->$action();}else{thrownew\Exception($action."方法不存在",1);}}else{thrownew\Exception($ctrl."控制器不存在",1);}}//自动加载class文件staticpublicfunctionautoload($class){$file=BASEPATH.'/'.str_replace('\\','/',$class).'.php';如果(is_file($file)){require_once($file);}else{返回错误;五、加载配置类frame/Libs/Config.phpcheckRoute($path[0]);if(!isset($path[0])||!$isExists){thrownew\Exception($path[0]."路由不存在",1);}}else{$this->ctrl='欢迎';$this->action='index';}}privatefunctioncheckRoute($alias){$routes=Config::get('Routes',null,true);foreach($routesas$key=>$value){foreach($valueas$k=>$v){if($k==$alias){$c=explode('@',$v);$this->ctrl=$c[0];$this->action=$c[1];$this->namespace=$key;返回真;}}}返回假;}}七、默认控制器app/Controllers/WelcomeController.phpHello,World欢迎使用PHP-FRAME框架");}}第八,隐藏index.php文件。.htaccess
