league/construct-finder
最新稳定版本:1.6.0
Composer 安装命令:
composer require league/construct-finder
包简介
Finds classes, interfaces, traits, and enums.
README 文档
README
This library helps you locate classes, interfaces, traits, and enums in PHP code. The construct finder locates all code constructs located in a directory.
Installation
composer require league/construct-finder
Usage
Finding constructs
You can find all constructs or use a type specific finder.
use League\ConstructFinder\ConstructFinder; // Find all constructs $constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findAll(); $constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findAllNames(); // Find all classes $constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findClasses(); $constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findClassNames() // Find all interfaces $constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findInterfaces(); $constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findInterfaceNames(); // Find all enums $constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findEnums(); $constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findEnumNames(); // Find all traits $constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findTraits(); $constructNames = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findTraitNames();
Using a construct
Constructs are simple value objects that expose the name and the type.
use League\ConstructFinder\Construct; use League\ConstructFinder\ConstructFinder; // Find all constructs $constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory')->findAll(); /** @var Construct $construct */ $construct = $constructs[0]; $name = $construct->name(); $name = (string) $construct; $type = $construct->type(); // class, trait, interface, enum
Finding in multiple directories
Provide multiple directories to search from in one go.
use League\ConstructFinder\ConstructFinder; // Find all constructs $constructs = ConstructFinder::locatedIn( __DIR__ . '/SomeDirectory', __DIR__ . '/AnotherDirectory', )->findAll();
Excluding files based on exclude patterns
All patterns are match in full. You can use a wildcard (*) for fuzzy matching.
use League\ConstructFinder\ConstructFinder; // Find all constructs $constructs = ConstructFinder::locatedIn(__DIR__ . '/SomeDirectory') ->exclude('*Test.php', '*/Tests/*') ->findAll();
league/construct-finder 适用场景与选型建议
league/construct-finder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.17M 次下载、GitHub Stars 达 44, 最近一次更新时间为 2021 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 league/construct-finder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 league/construct-finder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3.17M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 44
- 点击次数: 9
- 依赖项目数: 13
- 推荐数: 2
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-30