PHPackages                             wyrihaximus/list-classes-in-directory - 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. wyrihaximus/list-classes-in-directory

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

wyrihaximus/list-classes-in-directory
=====================================

Allows you to list full qualified class names in directories and files.

1.7.0(1y ago)23304.8k↑120.3%3[3 issues](https://github.com/WyriHaximus/php-list-classes-in-directory/issues)[5 PRs](https://github.com/WyriHaximus/php-list-classes-in-directory/pulls)6MITPHPPHP ^8.2

Since Oct 13Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/WyriHaximus/php-list-classes-in-directory)[ Packagist](https://packagist.org/packages/wyrihaximus/list-classes-in-directory)[ GitHub Sponsors](https://github.com/WyriHaximus)[ RSS](/packages/wyrihaximus-list-classes-in-directory/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (24)Used By (6)

List all PHP classes in directories and files
=============================================

[](#list-all-php-classes-in-directories-and-files)

[![Continuous Integration](https://github.com/WyriHaximus/php-list-classes-in-directory/actions/workflows/ci.yml/badge.svg)](https://github.com/WyriHaximus/php-list-classes-in-directory/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/da8896ebaad6b43dc3a59b72e454b815802bf2d043ff95d89c74b76d7be4f3c6/68747470733a2f2f706f7365722e707567782e6f72672f77797269686178696d75732f6c6973742d636c61737365732d696e2d6469726563746f72792f762f737461626c652e706e67)](https://packagist.org/packages/wyrihaximus/list-classes-in-directory)[![Total Downloads](https://camo.githubusercontent.com/bdd8a3cb97abc6e67cecbb619da4c2f88ebce24108dbedf7b74be3832ac8933b/68747470733a2f2f706f7365722e707567782e6f72672f77797269686178696d75732f6c6973742d636c61737365732d696e2d6469726563746f72792f646f776e6c6f6164732e706e67)](https://packagist.org/packages/wyrihaximus/list-classes-in-directory/stats)[![Code Coverage](https://camo.githubusercontent.com/96b8f5de7755f4c0fc911d76715176e17f40586c3ac1214c7f0251b4af2a44ea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f77797269686178696d75732f7068702d6c6973742d636c61737365732d696e2d6469726563746f72792f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wyrihaximus/php-list-classes-in-directory/?branch=master)[![License](https://camo.githubusercontent.com/abe43237f60f1292229e6e7be4c8d8e06233bea424827b60b2cea4c25e85f818/68747470733a2f2f706f7365722e707567782e6f72672f77797269686178696d75732f6c6973742d636c61737365732d696e2d6469726563746f72792f6c6963656e73652e706e67)](https://packagist.org/packages/wyrihaximus/list-classes-in-directory)

Install
=======

[](#install)

To install via [Composer](http://getcomposer.org/), use the command below, it will automatically detect the latest version and bind it with `^`.

```
composer require wyrihaximus/list-classes-in-directory

```

Usage
=====

[](#usage)

#### get a list of classes from multiple directories.

[](#get-a-list-of-classes-from-multiple-directories)

```
use function WyriHaximus\Lister;

// $classes now contains a list of full qualified class names from 'src/' and 'tests/'
$classes = Lister::classesInDirectories(
    __DIR__ . '/src',
    __DIR__ . '/tests'
);

// use listInstantiatableClassesInDirectories() or listNonInstantiatableClassesInDirectories() to only consider classes that can actually be instantiated, or not.
$instantiatableClasses = Lister::instantiatableClassesInDirectory(
    __DIR__ . '/src',
    __DIR__ . '/tests'
);
$nonInstantiatableClasses = Lister::nonInstantiatableClassesInDirectory(
    __DIR__ . '/src',
    __DIR__ . '/tests'
);
```

#### get a list of classes from one directory.

[](#get-a-list-of-classes-from-one-directory)

```
use function WyriHaximus\Lister;

// $classes now contains a list of full qualified class names from __DIR__
$classes = Lister::classesInDirectory(__DIR__);

// use listInstantiatableClassesInDirectory() or listNonInstantiatableClassesInDirectory() to only consider classes that can actually be instantiated, or not.
$instantiatableClasses = Lister::instantiatableClassesInDirectory(__DIR__);
$nonInstantiatableClasses = Lister::nonInstantiatableClassesInDirectory(__DIR__);
```

#### get a list of classes from multiple files.

[](#get-a-list-of-classes-from-multiple-files)

```
use function WyriHaximus\Lister;

// $classes now contains a list of full qualified class names from 'Bar.php' and 'Foo.php'
$classes = Lister::classesInFiles(
    __DIR__ . '/Bar.php',
    __DIR__ . '/Foo.php'
);
```

#### get a list of classes from one file.

[](#get-a-list-of-classes-from-one-file)

```
use function WyriHaximus\Lister;

// $classes now contains a list of full qualified class names from 'Foo.php'
$classes = Lister::classesInFile(__DIR__.'/Foo.php');
```

Acknowledgement
===============

[](#acknowledgement)

This package is a shorthand function for using [`better reflection`](https://github.com/Roave/BetterReflection/) and is based on one of the [`examples`](https://github.com/Roave/BetterReflection/blob/396a07c9d276cb9ffba581b24b2dadbb542d542e/demo/parsing-whole-directory/example2.php).

License
=======

[](#license)

The MIT License (MIT)

Copyright (c) 2024 Cees-Jan Kiewiet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance57

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 50% 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.

###  Release Activity

Cadence

Every ~191 days

Recently: every ~232 days

Total

12

Last Release

672d ago

PHP version history (3 changes)1.0.0PHP ^7.2

1.4.0PHP ^8 || ^7.4

1.6.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/147145?v=4)[Cees-Jan Kiewiet](/maintainers/WyriHaximus)[@WyriHaximus](https://github.com/WyriHaximus)

---

Top Contributors

[![WyriHaximus](https://avatars.githubusercontent.com/u/147145?v=4)](https://github.com/WyriHaximus "WyriHaximus (65 commits)")[![azjezz](https://avatars.githubusercontent.com/u/29315886?v=4)](https://github.com/azjezz "azjezz (23 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (16 commits)")[![holtkamp](https://avatars.githubusercontent.com/u/776405?v=4)](https://github.com/holtkamp "holtkamp (3 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (2 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (2 commits)")

---

Tags

hacktoberfestphpphp7php72

### Embed Badge

![Health badge](/badges/wyrihaximus-list-classes-in-directory/health.svg)

```
[![Health](https://phpackages.com/badges/wyrihaximus-list-classes-in-directory/health.svg)](https://phpackages.com/packages/wyrihaximus-list-classes-in-directory)
```

###  Alternatives

[roave/backward-compatibility-check

Tool to compare two revisions of a public API to check for BC breaks

5953.3M56](/packages/roave-backward-compatibility-check)[spatie/typescript-transformer

This is my package typescript-transformer

3706.5M16](/packages/spatie-typescript-transformer)[mateffy/laravel-introspect

Analyze Laravel codebases and find structured information about models, routes and other Laravel-specific things.

1698.7k2](/packages/mateffy-laravel-introspect)[bartlett/umlwriter

Create UML class diagrams from your PHP source.

6313.0k1](/packages/bartlett-umlwriter)[setasign/php-stub-generator

A tool to generate stub-files for your php classes.

302.1k1](/packages/setasign-php-stub-generator)[space48/auto-value

Generated immutable value classes for PHP7.1+

291.6k](/packages/space48-auto-value)

PHPackages © 2026

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