thecodingmachine/class-explorer
最新稳定版本:v1.1.0
Composer 安装命令:
composer require thecodingmachine/class-explorer
包简介
Find the list of all your classes and more.
关键字:
README 文档
README
Discover PHP classes in your project.
This project aim is to offer a set of classes enabling classes/interface/trait discovery in your own project.
Currently, the project contains only one implementation based on scanning files.
GlobClassExplorer
The GlobClassExplorer will look for all classes in a given namespace.
Usage
$explorer = new GlobClassExplorer('\\Some\\Namespace\\', $psr16Cache, $cacheTtl); $classes = $explorer->getClasses(); // Will return: ['Some\Namespace\Foo', 'Some\Namespace\Bar', ...]
This explorer:
- looks only for classes in YOUR project (not in the vendor directory)
- assumes that if a file exists in a PSR-0 or PSR-4 directory, the class is available (assumes the file respects PSR-1)
- makes no attempt at autoloading the class
- is pretty fast, even when no cache is involved
By default, GlobClassExplorer will load classes recursively in sub-namespaces. You can prevent it to load classes
recursively by passing false to the 5th parameter:
$explorer = new GlobClassExplorer('\\This\\Namespace\\Only\\', $psr16Cache, $cacheTtl, null, false);
You can also get a class map using the getClassMap method.
A class map is an array associating the name of the classes found (in key), to the file they are
linked to (the real path of the file).
$classMap = $explorer->getClassMap(); foreach ($classMap as $class => $file) { echo 'Class '.$class.' found in file '.$file; }
统计信息
- 总下载量: 2M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 1
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-29