定制 kcs/class-finder 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kcs/class-finder

最新稳定版本:0.6.1

Composer 安装命令:

composer require kcs/class-finder

包简介

Utility classes to help discover other classes/namespaces

README 文档

README

Utility classes to help discover other classes/namespaces

Tests codecov

Installation

$ composer require kcs/class-finder

Usage

Finder helps you to discover classes into your project.

The most common way to discover is to use the provided ComposerFinder. This will search for classes using the auto-generated class loader from composer and resolving PSR-* namespaces accordingly.

Read more in the docs at https://alekitto.github.io/class-finder/

Basic usage

use Kcs\ClassFinder\Finder\ComposerFinder;

$finder = new ComposerFinder();
foreach ($finder as $className => $reflector) {
    // Do magic things...
}

Filtering

You can filter classes using the methods exposed by FinderInterface:

  • implementationOf(array $interfaces): Finds the classes that implements all the given interfaces. You can pass a single interface as string.
  • subclassOf(string $superClass): Finds all the classes that are subclasses of the given class.
  • annontatedBy(string $annotationClass): Finds all the classes that have the given annotation in the class docblock.
  • withAttribute(string $attributeClass): Finds all the classes that have the given attribute applied on the class (PHP >= 8.0) only.
  • in(array $dirs): Searches only in given directories.
  • inNamespace(array $namespaces): Searches only in given namespaces.
  • filter(callable $callback): Custom filtering callback.
  • pathFilter(callable $callback): Custom filtering callback for loading files.

License

This library is released under the MIT license.

Contributions

Contributions are always welcome. Please feel free to open a PR or file an issue.

Thank you for reading
A.

统计信息

  • 总下载量: 1.25M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 31
  • 点击次数: 1
  • 依赖项目数: 14
  • 推荐数: 0

GitHub 信息

  • Stars: 31
  • Watchers: 3
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04