rooc / psr4_auto_loader
Implementation of the PSR-4 autoloading standard
v2.0.1
2017-06-12 15:09 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: >=5.7
This package is not auto-updated.
Last update: 2025-09-14 09:32:38 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