PHPackages                             ap-lib/directory-class-finder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ap-lib/directory-class-finder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ap-lib/directory-class-finder
=============================

DirectoryClassFinder is a lightweight PHP library for scanning directories and retrieving class names

029PHP

Since Feb 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ap-lib/directory-class-finder)[ Packagist](https://packagist.org/packages/ap-lib/directory-class-finder)[ RSS](/packages/ap-lib-directory-class-finder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

AP\\DirectoryClassFinder
========================

[](#apdirectoryclassfinder)

[![MIT License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

DirectoryClassFinder is a lightweight PHP library for scanning directories and retrieving class names. It supports both **recursive** and **non-recursive** searches and works with Composer's autoloading mechanisms.

Installation
------------

[](#installation)

```
composer require ap-lib/directory-class-finder
```

Features
--------

[](#features)

- Supports both recursive and non-recursive directory scanning.
- Works with Composer's PSR-4 autoloading and classmap caching for efficiency.
- Allows excluding vendor classes for better performance.
- Provides options for verifying class existence before yielding.

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Composer for autoloading

Getting started
---------------

[](#getting-started)

### Basic Usage

[](#basic-usage)

```
use AP\DirectoryClassFinder\DirectoryClassFinderComposerPSR4;

$classFinder = new DirectoryClassFinderComposerPSR4(
    include_vendor_classes: false,
    recheck_founded_by_psr4_name: true,
    recheck_founder_on_classmap: false
);

$classes = $classFinder->getClasses('/path/to/directory');

foreach ($classes as $class) {
    echo $class . PHP_EOL;
}
```

### Recursive vs Non-Recursive Search

[](#recursive-vs-non-recursive-search)

```
$recursiveClasses = $classFinder->getClasses('/path/to/directory', recursive: true); // Includes subdirectories
$nonRecursiveClasses = $classFinder->getClasses('/path/to/directory', recursive: false); // Only top-level
```

Advanced Usage
--------------

[](#advanced-usage)

### Using Composer's Autoload Optimization

[](#using-composers-autoload-optimization)

If you've run:

```
composer dump-autoload --optimize
```

You can leverage Composer's classmap caching to improve performance:

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1215fe5ecc9ba0ab1c730d3c992125cf6ebf460562e66be71ebae127789d465a?d=identicon)[AntonPanfilov](/maintainers/AntonPanfilov)

---

Top Contributors

[![anton-panfilov](https://avatars.githubusercontent.com/u/1083546?v=4)](https://github.com/anton-panfilov "anton-panfilov (3 commits)")

### Embed Badge

![Health badge](/badges/ap-lib-directory-class-finder/health.svg)

```
[![Health](https://phpackages.com/badges/ap-lib-directory-class-finder/health.svg)](https://phpackages.com/packages/ap-lib-directory-class-finder)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
