PHPackages                             gamingengine/classfinder - 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. gamingengine/classfinder

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

gamingengine/classfinder
========================

Automatic class discovery via Composer autoloader

0556—5%PHPCI passing

Since Feb 21Pushed 4mo agoCompare

[ Source](https://github.com/gaming-engine/classfinder)[ Packagist](https://packagist.org/packages/gamingengine/classfinder)[ RSS](/packages/gamingengine-classfinder/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

ClassFinder
===========

[](#classfinder)

Runtime class discovery for PHP using Composer's PSR-4 autoloader. Find classes that implement an interface, extend a base class, or use a specific attribute — without maintaining manifests or config files.

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

[](#requirements)

- PHP 8.4+
- Composer (PSR-4 autoloading)

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

[](#installation)

```
composer require gamingengine/classfinder
```

Usage
-----

[](#usage)

### Find classes that implement an interface

[](#find-classes-that-implement-an-interface)

```
use GamingEngine\ClassFinder\ClassFinder;

$implementations = ClassFinder::interfaces(MyInterface::class);
// ['App\Services\ConcreteA', 'App\Services\ConcreteB']
```

### Find subclasses of a base class

[](#find-subclasses-of-a-base-class)

```
$subclasses = ClassFinder::classes(BaseHandler::class);
// ['App\Handlers\EmailHandler', 'App\Handlers\SmsHandler']
```

### Find classes with a specific attribute

[](#find-classes-with-a-specific-attribute)

```
$tagged = ClassFinder::withAttribute(AsCommand::class);
// ['App\Commands\ImportData', 'App\Commands\ExportData']
```

### Namespace filtering

[](#namespace-filtering)

All discovery methods accept a namespace parameter to limit the search scope. This defaults to `GamingEngine\\` but can be set to any namespace registered in Composer's PSR-4 autoloader.

```
// Search only within a specific namespace
$modules = ClassFinder::interfaces(ModuleContract::class, 'App\\Modules\\');

// Search across all registered namespaces
$all = ClassFinder::interfaces(ModuleContract::class, '');
```

### Caching

[](#caching)

Results are cached in memory for the lifetime of the request using an `ArrayMemoizer`. You can flush the cache or swap in your own implementation:

```
use GamingEngine\ClassFinder\ClassFinder;
use GamingEngine\ClassFinder\Contracts\MemoizerContract;

// Flush the cache
ClassFinder::flush();

// Use a custom memoizer (e.g. Redis, filesystem)
ClassFinder::setMemoizer(new class implements MemoizerContract {
    public function remember(string $key, callable $callback): mixed
    {
        return Cache::remember($key, 3600, $callback);
    }

    public function flush(): void
    {
        Cache::flush();
    }
});
```

How it works
------------

[](#how-it-works)

ClassFinder reads Composer's registered PSR-4 prefixes via `ClassLoader::getPrefixesPsr4()` and recursively scans the corresponding directories for PHP files. It parses each file to extract the fully qualified class name, then uses reflection to check whether it matches the given criteria.

Classes under `\Tests\` namespaces are automatically excluded.

License
-------

[](#license)

MIT

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance52

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

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/6c1a37465afdee14b2740a387deaae40ac376e38015db7af98f90b7fd97fed22?d=identicon)[awjudd](/maintainers/awjudd)

### Embed Badge

![Health badge](/badges/gamingengine-classfinder/health.svg)

```
[![Health](https://phpackages.com/badges/gamingengine-classfinder/health.svg)](https://phpackages.com/packages/gamingengine-classfinder)
```

###  Alternatives

[hexbit/router

Wordpress Router

352.9k](/packages/hexbit-router)

PHPackages © 2026

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