folder * @param string $path */ public function PluginLoader(string $path) { // //TODO if is necessary to give a priority to some classes before other, initialize here Global $System, $Web; $System = new System(); // we need System Base class first, so will force to load as first $Web = new Web(); // $Directory = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); $Iterator = new RecursiveIteratorIterator($Directory, RecursiveIteratorIterator::CHILD_FIRST); foreach($Iterator as $item) { if (is_file($item->getPathname())) continue; $moduleName = $item->getFilename(); $className = str_replace('/', '\\', ltrim("{$item->getPathname()}/{$moduleName}", $path)); // Load only PHP file with same name of namespace ex.: \Lamborghini\Lamborghini.php $moduleInitPath = "{$item->getPathname()}/{$moduleName}.php"; if (file_exists($moduleInitPath)) { // If already imported, skip if (!isset($$moduleName)) { Global $$moduleName; // Declare visibility to Global $$moduleName = new $className(); // Instantiate the Module, all init procedure must reside in __constructor() method } } } } /** * Use F3 template resolve() to parse string like "{{@BASESITE}}" * * @param string $strTemplate the F3 original string * @return string converted string */ public function getStringFromTemplate(string $strTemplate) { return \Template::instance()->resolve($strTemplate); } /** * Load an encrypted file with the method "base64_encode(gzcompress())", save it in a temporary file in temp folder of system and load with F3::config() * * @param string $path * @throws \Exception */ public function LoadEncryptedConfig(string $path) { if(!file_exists($path)) throw new \Exception('Config file not found'); $tmpFilepath = tempnam(sys_get_temp_dir(), 'om'); $config = gzuncompress(base64_decode(file_get_contents($path))); file_put_contents($tmpFilepath, $config); \F3::config($tmpFilepath, true); unlink($tmpFilepath); } public function DieByOldPhpVersion() { if (version_compare(PHP_VERSION, '7.2') != 1) throw new \Exception('PHP 7.2+ is need to run the project'); } }