<?php
 spl_autoload_register(function ($class) { $prefixToLocation = [ "Square\\" => "/square-php-sdk/src/", "apimatic\\jsonmapper\\" => "/jsonmapper/src/", "Unirest\\" => "/unirest-php/src/Unirest/", ]; $matchingPrefix; foreach ($prefixToLocation as $prefix => $location) { $len = strlen($prefix); if (strncmp($prefix, $class, $len) !== 0) { continue; } else { $matchingPrefix = $prefix; } } if (!$matchingPrefix) { return; } $base_dir = (__DIR__ . $prefixToLocation[$matchingPrefix]); $relative_class = substr($class, strlen($matchingPrefix)); $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; if (file_exists($file)) { require $file; } });