PHP Classes

File: class_loader.php

Recommend this page to a friend!
  Classes of Cuthbert Martin Lwinga   Dyno SQL   class_loader.php   Download  
File: class_loader.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Dyno SQL
Build and execute SQL queries dynamically
Author: By
Last change:
Date: 3 months ago
Size: 680 bytes
 

Contents

Class file image Download
<?php

function loadClasses($directory = __DIR__) {
   
$iterator = new RecursiveIteratorIterator(
        new
RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS),
       
RecursiveIteratorIterator::SELF_FIRST
   
);

    foreach (
$iterator as $file) {
        if (
$file->isFile() && $file->getExtension() === 'php') {
           
$filePath = $file->getRealPath();
           
           
// Skip the current file to avoid infinite recursion
           
if ($filePath === __FILE__) {
                continue;
            }

            require_once
$filePath;
           
//echo "Loaded: " . $filePath . PHP_EOL;
       
}
    }
}


loadClasses();


?>