文件
fenleixinxi/application/api/controller/Probe.php

54 行
2.1 KiB
PHP

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace app\api\controller;
use think\Config;
use think\Route;
/**
* 路由诊断探针(临时,验证完成后删除)
* 访问:GET /api/probe/index
*/
class Probe extends \app\common\controller\Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function index()
{
// TP5.0 无 Route::getRules(),用反射读取静态 $rules
$ref = new \ReflectionClass(Route::class);
$prop = $ref->getProperty('rules');
$prop->setAccessible(true);
$rules = $prop->getValue();
$getBucket = isset($rules['get']) ? $rules['get'] : [];
$starBucket = isset($rules['*']) ? $rules['*'] : [];
$out = [
'request_path' => $this->request->path(),
'request_pathinfo' => $this->request->pathinfo(),
'request_module' => $this->request->module(),
'request_controller' => $this->request->controller(),
'request_action' => $this->request->action(),
'server_PATH_INFO' => isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : null,
'get_s' => isset($_GET['s']) ? $_GET['s'] : null,
'url_route_on' => Config::get('url_route_on'),
'route_config_file' => Config::get('route_config_file'),
'pathinfo_depr' => Config::get('pathinfo_depr'),
'CONF_PATH' => CONF_PATH,
'route_file_exists' => is_file(CONF_PATH . 'route.php'),
'runtime_route_file' => is_file(RUNTIME_PATH . 'route.php'),
'rule_buckets' => array_keys($rules),
'get_bucket_count' => count($getBucket),
'star_bucket_count' => count($starBucket),
'get_sample' => array_slice(array_keys($getBucket), 0, 8),
'has_static_rule' => isset($getBucket['api/v1/home/banners']),
'star_has_static' => isset($starBucket['api/v1/home/banners']),
];
echo json_encode($out, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
}
}