hyperfk8s/config/routes.php

49 lines
1.2 KiB
PHP
Executable File

<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
use Hyperf\HttpServer\Router\Router;
//Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index');
//
//Router::get('/favicon.ico', function () {
// return '';
//});
# php bin/hyperf.php describe:routes 查看注册路由
$path = BASE_PATH . '/routes';
function loopFolders($dir)
{
// 打开文件夹
$handle = opendir($dir);
// 遍历文件夹中的每个文件及子文件夹
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..') {
$filePath = $dir . '/' . $file;
// 检查文件类型
if (is_dir($filePath)) {
// 如果是子文件夹,则递归遍历
loopFolders($filePath);
} else {
require_once $filePath;
}
}
}
// 关闭文件夹句柄
closedir($handle);
}
// 调用函数并传入顶层文件夹路径
loopFolders($path);