<?php
spl_autoload_register(function ($class) {
    $prefixes = [
        'PhpOffice\\PhpSpreadsheet\\' => __DIR__ . '/PhpSpreadsheet/src/PhpSpreadsheet/',
        'Psr\\SimpleCache\\'          => __DIR__ . '/Psr/SimpleCache/',
		'Composer\\Pcre\\' 			  => __DIR__ . '/composer-pcre/src/',
        'Complex\\'                   => __DIR__ . '/Math/Complex/',
        'Matrix\\'                    => __DIR__ . '/Math/Matrix/',
        'DeepCopy\\'                  => __DIR__ . '/MyCLabs/DeepCopy/',
		'PHPMailer\\'                 => __DIR__ . '/PHPMailer/src/', 
    ];

    foreach ($prefixes as $prefix => $baseDir) {
        if (strpos($class, $prefix) === 0) {
            $relativeClass = substr($class, strlen($prefix));
            $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
            if (file_exists($file)) {
                require $file;
                return;
            }
        }
    }
});