1.在extend目录下新建要定义的扩展类:如下图所示
2.定义扩展类的内容
<?phpnamespace org;/****/class Auth{
public function __construct(){
# code...}public function xx() {
echo 'xxxxxxxxxxxxxx';}}
3.在控制器中调用自定义的扩展类
<?phpnamespace app\index\controller; use think\Controller; use org\Auth; //引入扩展类class Index extends Controller {
public function index(){
$a = new Auth();$a->xx();} }
4.结果如下
xxxxxxxxxxxxxx