route.php <?phpclass app{public function appInit():self{if(glob("./controller/*.php")){foreach(glob("./controller/*.php") as $fileName){require_once($fileName);$className = str_replace("./controller/","",str_replace(".php","",$fileName));route::setRoute($className);//route::$all;exit();}}return $this;}public function run($config){$controller = $_GET['c']??$config['default_controller'];$action = $_GET['a']??$config['default_function'];if(isset(route::$all[$controller][$action])){$route = route::$all[$controller][$action];$className = $route->controller;$function = $route->function;(new $className)->$function();}else{exit("404 Not Found!");}}}init.php <?phpclass indexController{#[route('/controller/index','get')]public function index():void{echo "This is attribute index controller \r\n";}#[route('/controller/test','get')]public function test():void{echo "This is attribute test controller \r\n";}}indexController.php <?phpclass workController{#[route('/controller/work','post')]public function work():void{echo "This is attribute work controller \r\n";}}workController.php <?php$config = array('default_controller'=>'index','default_function'=>'index',);return $config;config.php <?phprequire_once('./config.php');require_once('./route.php');require_once('./init.php');(new app)->appInit()->run($config);index.php
经验总结扩展阅读
- netty系列之: 在netty中使用 tls 协议请求 DNS 服务器
- 使用LabVIEW实现基于pytorch的DeepLabv3图像语义分割
- 高压锅买回来可以直接使用吗
- 天猫精灵cc7怎么使用_天猫精灵cc7使用方法
- 砂锅第一次使用怎样开锅
- iPadmini6使用体验_iPadmini6使用感受
- 高光的使用是用在定妆之前还是之后?
- 皙之密1到9号使用步骤是什么?
- 西瓜水弄衣服上怎么洗干净
- Nginx 使用自签名证书实现 https 反代 Spring Boot 中碰到的页面跳转问题

 
   
   
   
   
   
   
   
   
   
   
   
  