rooc / psr4_auto_loader
Implementation of the PSR-4 autoloading standard
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/rooc/psr4_auto_loader
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: >=5.7
This package is not auto-updated.
Last update: 2025-10-12 09:47:10 UTC
README
Implementation of the PSR-4 autoloading standard.
Requirements
- PHP >=7.1 (for PHP >=5.6 support use version 1.0)
- PHPUnit >=5.7 (for running tests)
Installation
Via Composer:
composer require "rooc/psr4_auto_loader"
Usage
For example, in the project root we have "src" folder that contains our own code of classes, interfaces, traits etc. Let's load all of them:
$autoLoader = new \Rooc\PSR4AutoLoader\PSR4AutoLoader('./src', 'App'); $autoLoader->register();
If your code are in several directories, e. g. "Classes" and "Interfaces", you need register both:
use Rooc\PSR4AutoLoader\PSR4AutoLoader; // Load classes (new PSR4AutoLoader('./Classes', 'App'))->register(); // Load interfaces (new PSR4AutoLoader('./Interfaces', 'App'))->register();
Note that you should follow the PSR-4 class naming rules: http://www.php-fig.org/psr/psr-4/#specification
License
MIT