Browse Source

修正windos的文件路径兼容

master
chenlong 8 months ago
parent
commit
efd4dd1f5b
  1. 4
      Admin/Service/ApiDocService.php
  2. 2
      Install.php

4
Admin/Service/ApiDocService.php

@ -71,6 +71,9 @@ class ApiDocService
$apiList = []; $apiList = [];
foreach ($paths as ['path' => $path, 'namespace' => $namespace, 'namespace_root' => $namespaceRoot, ]) { foreach ($paths as ['path' => $path, 'namespace' => $namespace, 'namespace_root' => $namespaceRoot, ]) {
$namespaceRoot = strtr(strtr($namespaceRoot, ['\\' => '/']), ['/' => DIRECTORY_SEPARATOR]);
$path = strtr(strtr($path, ['\\' => '/']), ['/' => DIRECTORY_SEPARATOR]);
$MPaths = $this->getPaths($path); $MPaths = $this->getPaths($path);
foreach ($MPaths as $MPath) { foreach ($MPaths as $MPath) {
@ -82,6 +85,7 @@ class ApiDocService
} }
$classFullName = implode("\\", [$namespace, ...explode(DIRECTORY_SEPARATOR, strtr(dirname($eachFile->filepath), [$namespaceRoot => ''])), $classname]); $classFullName = implode("\\", [$namespace, ...explode(DIRECTORY_SEPARATOR, strtr(dirname($eachFile->filepath), [$namespaceRoot => ''])), $classname]);
$classFullName = preg_replace('/\\\+/', '\\', $classFullName); $classFullName = preg_replace('/\\\+/', '\\', $classFullName);
try { try {
if (!class_exists($classFullName)) { if (!class_exists($classFullName)) {
return; return;

2
Install.php

@ -13,7 +13,7 @@ class Install implements PluginsInstallInterface
echo "ApiDoc 安装成功。\n"; echo "ApiDoc 安装成功。\n";
echo "示例代码查看 ApiDoc/Controller/DemoController.php。\n"; echo "示例代码查看 ApiDoc/Controller/DemoController.php。\n";
echo "示例效果查看文档访问地址。\n"; echo "示例效果查看文档访问地址。\n";
echo "文档访问地址: {$_SERVER["SERVER_NAME"]}/admin/plugins/api-doc\n"; echo "文档访问地址: http://127.0.0.1/admin/plugins/api-doc\n";
echo "===============================================================\n"; echo "===============================================================\n";
} }
} }
Loading…
Cancel
Save