Commit 7c03d6ea by zhufx

1.自建组件,支持配置扫描目录

parent c28249a3
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/16
* Time: 11:09
*/
$basePath = dirname(__DIR__,3);
/**
* 用于自建组件扫描路径配置(键值是方便开发人员理解,代码中无意义)
* [
* 'commonPath' => $basePath.'/Common',
* 'enmu' => $basePath.'/Order/Enum',
*
* ];
*/
return [
'commonPath' => $basePath.'/Common',
];
\ No newline at end of file
......@@ -5,19 +5,19 @@
* Date: 2018/7/16
* Time: 9:32
*/
$basePath = dirname(__DIR__,3);
$scanPaths = include __DIR__.'/PathConfig.php';
$data = [];
$files = \Swoft\Helper\DirHelper::glob($basePath,'*.php');
foreach ($scanPaths as $basePath) {
$files = \Swoft\Helper\DirHelper::glob($basePath,'*.php');
$baseNamespace = "Hdll\Services\\";
$baseNamespace = "Hdll\Services";
$data = [];
foreach ( $files as $file ) {
$path = dirname($file);
$suffixNamespace = str_replace($basePath,"",$path);
$suffixNamespace = str_replace("/","\\",$suffixNamespace);
foreach ( $files as $file ) {
$pathSpace = str_replace("/var/www/swoft/vendor/hdll/services/src/","",$file);
$pathSpace = dirname($pathSpace);
$pathSpace = str_replace("/","\\",$pathSpace);
$namespace = $baseNamespace.$suffixNamespace;
$namespace = $baseNamespace.$pathSpace;
$fileName = basename($file,'.php');
......@@ -43,8 +43,7 @@ foreach ( $files as $file ) {
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment