```
//獲取模塊下所有的控制器和方法
public function initperm() {
$modules = array('api'); //模塊名稱
$i = 0;
foreach ($modules as $module) {
$all_controller = $this->getController($module);
foreach ($all_controller as $controller) {
$all_action = $this->getAction($module, $controller);
foreach ($all_action as $action) {
$controller = str_replace('Controller', '', $controller);
$data[$i]['module'] = $module;
$data[$i]['controller'] = $controller;
$data[$i]['action'] = $action;
//入庫
if (!empty($module) && !empty($controller) && !empty($action)) {
$rule_name = $module . '/' . $controller . '/' . $action;
if (!$rule) {
$idata = array();
$idata['module'] = strtolower($module . '/' . $controller);
$idata['type'] = "1";
$idata['name'] = strtolower($rule_name);
$idata['title'] = "";
$idata['regex'] = "";
$idata['status'] = "1";
}
}
$i++;
}
}
}
return $data;
// echo '<pre>';
// print_r($data);
// echo '</pre>';
}
//獲取所有控制器名稱
private function getController($module) {
if (empty($module)) {
return null;
}
$module_path = APP_PATH . '/' . $module . '/controller/'; //控制器路徑
if (!is_dir($module_path)) {
return null;
}
$module_path .= '/*.php';
$ary_files = glob($module_path);
foreach ($ary_files as $file) {
if (is_dir($file)) {
continue;
} else {
$files[] = basename($file, '.php');
}
}
return $files;
}
//獲取所有方法名稱
protected function getAction($module, $controller) {
if (empty($controller)) {
return null;
}
$customer_functions = [];
$file = APP_PATH . $module . '/controller/' . $controller . '.php';
if (file_exists($file)) {
$content = file_get_contents($file);
preg_match_all("/.*?public.*?function(.*?)\(.*?\)/i", $content, $matches);
$functions = $matches[1];
//排除部分方法
$inherents_functions = array('_initialize', '__construct', 'getActionName', 'isAjax', 'display', 'show', 'fetch', 'buildHtml', 'assign', '__set', 'get', '__get', '__isset', '__call', 'error', 'success', 'ajaxReturn', 'redirect', '__destruct', '_empty');
foreach ($functions as $func) {
$func = trim($func);
if (!in_array($func, $inherents_functions)) {
$customer_functions[] = $func;
}
}
return $customer_functions;
} else {
// \ticky\Log::record('is not file ' . $file, Log::INFO);
return false;
}
return null;
}
```
- 課程介紹
- thinkphp5.0
- 安裝
- 開發規范
- 目錄結構
- 配置參數
- 系統常量
- tp5自帶的函數
- 助手函數
- 擴展類庫
- 基本類庫
- Workerman
- think-queue
- 驗證碼
- 圖片
- 權限認證
- 課前準備
- 數據庫設計
- 模塊設計
- 管理員管理
- 添加
- 編輯
- 刪除和批量刪除
- 列表頁
- 實列
- 權限管理
- 操作日志
- 基于行為的日記錄
- 行為日志的擴展
- 助手類庫
- 自建函數
- 將數組轉成uri字符串
- 獲取當前服務器的IP
- curl-post
- 截取文字中間的字符串
- 檢查中文姓名
- 省市區分別截取
- 抽獎概率問題
- 短信郵箱模板替換
- 生成csv
- PHP 圖片轉base64
- 銀行卡驗證
- json返回接口封裝
- 無限極分類
- 病毒
- xml和數組互轉
- xml轉成數組
- 數組轉xml
- tp控制器相關
- 獲取thinkph5下控制器和方法名
- 后臺查詢的簡單封裝
- 網址信息
- 獲取網站logo
- 判斷url是否存在
- 獲取title
- 判斷遠程文件是否存在
- 獲取頁面所有鏈接
- 過濾
- 截取
- 時間
- 獲取服務器信息
- 根據id生成唯一邀請碼
- 隨機顏色
- 數組字符串互換
- 創建多級目錄
- 懶人查詢
- 時間和時間戳轉換
- 房間id生菜
- 獲取需要的數組元素
- 文件和文件夾
- 文件類庫
- 文件夾
- 七牛云
- 七牛云運用場景
- 七牛云使用實例
- 郵箱
- 郵箱驗證
- 郵箱發送
- 數據庫
- 數據庫在thinkphp中的補充方法
- 備份和安全
- sql執行
- 數據庫備份2
- 時間日歷
- 時間格式化
- 日歷
- 圖片相關
- 自動獲取圖片主題顏色
- 獲取html中的圖片路徑
- 獲取圖片場景
- 獲取圖片實踐
- 圖片處理類
- 圖片處理場景
- 圖片處理實踐
- 數據驗證分析
- 身份證相關
- 新聞
- 自建類庫
- 簡易分類庫
- php 壓縮CSS代碼
- 身份證
- 分詞和抽詞
- 分詞應用場景
- 分詞實踐
- 中文轉拼音
- 中文轉拼音場景
- 中文轉拼音實踐
- 二維碼操作
- 二維碼場景
- 二維碼實踐
- 短地址
- PHPWord
- 插件化
- 插件擴展庫
- 插件列表
- 插件安裝和卸載
- 插件實踐
- 插件的離線安裝
- 計劃任務
- 計劃任務安裝
- 計劃任務實踐
- 定時器
- 注冊登錄
- 普通登錄注冊
- 第三方登錄注冊
- jwt接口登錄注冊
- 短信
- 飛鴿短信
- 阿里短信
- 消息隊列
- 網站地圖
- 全站靜態化
- 緩存
- 文件導出
- PDF生成
- phpword
- PHPExcel
- 其他類庫
- 百度
- 百度語音
- 快遞
- 跨域問題
- 寶塔
- 搜索記錄