From 1e0e85f9c356c8350be38f9a29ad14ad72e91d08 Mon Sep 17 00:00:00 2001 From: Saeed Vaziry Date: Sun, 23 Feb 2025 16:57:35 +0100 Subject: [PATCH 1/2] Add custom loaders --- index.php | 4 +++- src/Cli.php | 19 +++++++++++++++++++ src/Loader.php | 31 ++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/Cli.php diff --git a/index.php b/index.php index 0675ddd..2d3fbb1 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,6 @@ Date: Tue, 25 Feb 2025 17:54:42 +0100 Subject: [PATCH 2/2] load from base64 --- src/Loader.php | 19 ++++++------------- src/Loaders/BaseLoader.php | 5 +++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Loader.php b/src/Loader.php index aded027..b12d3bd 100644 --- a/src/Loader.php +++ b/src/Loader.php @@ -14,10 +14,10 @@ class Loader /** * @return null|LoaderInterface */ - public static function load(string $path, ?string $loaderPath = null) + public static function load(string $path, ?string $encodedLoader = null) { - if ($loaderPath !== null) { - $loaderClass = self::getLoaderClassFromPath($loaderPath); + if ($encodedLoader !== null) { + $loaderClass = self::getLoaderClassFrom($encodedLoader); if ($loaderClass !== null) { return new $loaderClass($path); @@ -47,20 +47,13 @@ public static function load(string $path, ?string $loaderPath = null) return null; } - private static function getLoaderClassFromPath(string $path) + private static function getLoaderClassFrom(string $encodedLoader) { - if (! file_exists($path)) { - return null; - } - $declaredClassesBefore = get_declared_classes(); - - require_once $path; - + $loader = base64_decode($encodedLoader); + eval(str_replace('