PHP code example of actra / autoloader

1. Go to this page and download the library: Download actra/autoloader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

actra / autoloader example snippets




use actra\autoloader\Autoloader;
use actra\autoloader\AutoloaderPath;

// Register the autoloader
$autoloader = Autoloader::register();

// Add a path for a namespace
$autoloader->addPath(autoloaderPath: new AutoloaderPath(
    path: __DIR__ . '/src',
    prefix: 'MyProject\\'
));

use actra\autoloader\Autoloader;
use actra\autoloader\AutoloaderPath;
use actra\autoloader\AutoloaderPathMode;

$autoloader = Autoloader::register();

$autoloader->addPath(autoloaderPath: new AutoloaderPath(
    path: __DIR__ . '/lib',
    prefix: 'Legacy_',
    autoloaderPathMode: AutoloaderPathMode::PSR0
));

$autoloader = Autoloader::register(cacheFilePath: __DIR__.' /cache/autoloader.php');

$autoloader->addPath(autoloaderPath: new AutoloaderPath(
    path: __DIR__ . '/src',
    prefix: 'App\\',
    fileSuffixList: ['.php', '.class.php', '.inc']
));