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-8?q?=CC=97=CC=96=CC=A4=CC=99=CC=9C=CD=8De=CC=BF=CC=AB=CD=8E=CC=9F?= =?UTF-8?q?=CC=BC=CC=BA=CC=ABr=CC=8A=CC=91=CC=BF=CC=85=CD=AF=CD=99=CD=85?= =?UTF-8?q?=CC=B0=29=CD=86=CC=87=CD=A7=CC=9A=CD=91=CC=AA=CC=96=CD=87=CC=9D?= =?UTF-8?q?=CC=AE=CC=AA=CD=96=CC=A6?= Date: Mon, 6 Sep 2021 17:18:00 -0400 Subject: [PATCH] Create autoload.php Allow for non-composer users to download from github releases and work with the package on no shell accounts (sans composer), like FTP, ect. --- autoload.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 autoload.php diff --git a/autoload.php b/autoload.php new file mode 100644 index 0000000..8ed2144 --- /dev/null +++ b/autoload.php @@ -0,0 +1,30 @@ + $classpaths) { + if (!is_array($classpaths)) { + $classpaths = array($classpaths); + } + spl_autoload_register(function ($classname) use ($namespace, $classpaths, $dir) { + // Check if the namespace matches the class we are looking for + if (preg_match("#^".preg_quote($namespace)."#", $classname)) { + // Remove the namespace from the file path since it's psr4 + $classname = str_replace($namespace, "", $classname); + $filename = preg_replace("#\\\\#", "/", $classname).".php"; + foreach ($classpaths as $classpath) { + $fullpath = $dir."/".$classpath."/$filename"; + if (file_exists($fullpath)) { + include_once $fullpath; + } + } + } + }); + } +} + +loadPackage(__DIR__."/");