Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Class Finder Laravel Package

kcs/class-finder

Discover and filter PHP classes and namespaces in your project using Composer’s autoloader with PSR resolution. Iterate found classes and reflections, then narrow results by interfaces, subclasses, annotations, PHP 8 attributes, directories, namespaces, or custom callbacks.

View on GitHub
Deep Wiki
Context7

ClassFinder

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky