thinkphp5.0如何让api接口从单文件解除耦合到多class文件

浏览:409 发布日期:2019/06/18 分类:求助交流
目前接口是通过单入口判定的
http://www.123.com/api/index/index?type=xxx&user=1index.php
class Index extends Controller
{
     protected $user_id;
     public function index(){
            $this->user_id=input("get.user_id","0");
            $type=input("get.type");
            return $this->$type;
     } 
     public function xxx(){
            echo $this->user_id;
            exit;
     } 
}
这种方式的缺点就是一个文件太多方法了。。。快上百个函数,有没有办法接口入口地址不变的情况下拆分成多个文件?
例如index.php

class Index extends Controller
{
     protected $user_id;
     public function index(){
            $this->user_id=input("get.user_id","0");
            $type=input("get.type");
            return $this->$type;
     } 
}


b.php

class b extends Controller
{
    
     public function xxx(){
            echo $this->user_id;
            exit;
     } 
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>