krzysztof-moskalik/class-loader

Simple tool to load all classes from given directory

v0.5.4 2021-02-28 01:44 UTC

This package is auto-updated.

Last update: 2024-04-28 09:23:00 UTC


README

This is a simple tool to get class object from given directory.

Usage

Basic usage:

$loader = new ClassLoader();
$objects = $loader->loadClassesFromDirectory(
    __DIR__ . '/src/'
);

This will return objects from all classes that exists in ./src directory.

If your classes needed some _construct arguments, you can pass them as second argument.

Third argument is used for filtering returned objects base on instanceof function, so you can only get children of given class or those implementing specified interface.