koriym/psr4list

Returns the name of the classes in PSR4 path

Maintainers

πŸ‘ koriym

Package info

github.com/koriym/Koriym.Psr4List

pkg:composer/koriym/psr4list

Statistics

Installs: 644 923

Dependents: 4

Suggesters: 0

Stars: 0

Open Issues: 0

1.4.0 2025-10-27 01:52 UTC

Requires

  • php: >=7.0

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT fad3dbc0f0ff74f3da26bf0b0a0413720ea7fcda

  • Akihito Koriyama <akihito.koriyama.woop@gmail.com>

psr4

This package is auto-updated.

Last update: 2026-06-27 03:16:47 UTC


README

πŸ‘ Scrutinizer Code Quality
πŸ‘ Code Coverage
πŸ‘ Continuous Integration (legacy)

Koriym\Psr4List is a simple library for retrieving a list of all classes and files corresponding to a specified namespace prefix and directory, based on the PSR-4 autoloading standard.

Installation

You can install the library via Composer:

composer require koriym/psr4list

Usage

Here’s a basic example of how to use Koriym\Psr4List:

use Koriym\Psr4List\Psr4List;

$list = new Psr4List;
$prefix = 'BEAR\Sunday'; // Namespace prefix
$path = __DIR__ . '/src'; // Corresponding directory

foreach ($list($prefix, $path) as list($class, $file)) {
 echo "Class: $class\n";
 echo "File: $file\n";
}

Example Output

Class: BEAR\Sunday\Module\AppModule
File: /path/to/project/src/Module/AppModule.php
Class: BEAR\Sunday\Extension\Router\RouterInterface
File: /path/to/project/src/Extension/Router/RouterInterface.php

Features

  • PSR-4 Compliant: Works based on the PSR-4 autoloading standard.
  • Simple and Lightweight: Minimal dependencies, easy to integrate into any project.
  • Flexible: Perfect for enumerating classes within a specific namespace.

Use Cases

  • Enumerate all classes under a specific namespace in your project.
  • Verify the correspondence between classes and their files.
  • Use as part of refactoring or code analysis tools.

License

This library is licensed under the MIT License.