tp 阅读手册

发布时间 2023-04-25 15:20:59作者: 东方素

1.依赖注入,将类以参数的形式传入方法中, 相当于在方法中 new Store();

namespace app\api\controller;
use model\ModelEntity as Store;
class Api{
  //依赖注入 Store,相当于在方式中已 $store = new Store();
  public function storeList(Store $store){
    $list = $store->getList();
  }
}