/* LOAD CLASSES IN DIRECTORY */ echo '<br><b>AUTOLOADING CLASSES ADDED WITH "addDirs( )" METHOD:</b><br><br>'; $class1 = new HmTestClass(); // loading a class from the directory $lowercase = new HmTestClassLs(); // loading a class with the filename lowercase /* ADDING A NAMESPACED DIRECTORY WITH CLASSES TO THE AUTOLOADER */ PtcHandyMan::addDir(array('nsTest' => PtcHandyMan::getAppPath('lib') . '/namespaceTest')); /* LOAD NAMESPACED CLASSES IN DIRECTORY */ echo '<br><b>AUTOLOADING NAMESPACED CLASSES ADDED WITH "addDirs( )" METHOD:</b><br><br>'; $class_ns = new nsTest\HmTestNs(); // loading a namespaced class $class_ns_deep = new nsTest\hmNsDeep\HmTestNsDeep(); // loading a namespaced class inside a subfolder /* LOAD CLASSES BASED ON SEPARATORS AND NAMING CONVENTIONS (LOADS SLOWER) */ echo '<br><b>AUTOLOADING CLASSES BASED ON SEPARATORS AND NAMING CONVENTIONS:</b><br><br>'; PtcHandyMan::addDir(PtcHandyMan::getAppPath('lib') . '/test-separators'); // adding the directory PtcHandyMan::addSeparator('-'); // adding a separator for class names PtcHandyMan::addConvention('{CLASS}'); // adding a naming convention ( {CLASS} , {SEP} ) $sep_class = new Hm_Test_Sep(); // loads by replacing the "_" with "-" added separator in the class name PtcHandyMan::addConvention('class.{CLASS}'); // adding another naming convention $sep_class1 = new Hm_Test_Sep1(); // loads by replacing the "_" with "-" added separator in the class name /* GETTING THE DIRECTORIES OF THE AUTOLOADER */ $dirs = PtcHandyMan::getDirs(); // getting all directories ( files , directories , ns )
public function __construct() { $dir = PtcHandyMan::getDirs('directories'); echo 'Class "' . __CLASS__ . '" autoloaded from directory:<br> ' . $dir[1] . ' - ' . basename(__FILE__) . '<br><br>'; }
public function __construct() { $dir = \PtcHandyMan::getDirs('ns'); echo 'Class "' . __CLASS__ . '" autoloaded, namespace "' . __NAMESPACE__ . '" example: <br> ' . $dir[__NAMESPACE__] . ' - ' . basename(__FILE__) . '<br><br>'; }
public function __construct() { $dir = PtcHandyMan::getDirs('directories'); echo 'Class "' . __CLASS__ . '" autoloaded from directory by replacing "_" with "-" separator:<br> ' . $dir[2] . ' - ' . basename(__FILE__) . '<br><br>'; }
public function __construct() { $dir = PtcHandyMan::getDirs('directories'); echo 'Class "' . __CLASS__ . '" autoloaded lowercase file name, from directory by replacing "_" with "-" separator, using naming convention "class.{CLASS}":<br> ' . $dir[2] . ' - ' . basename(__FILE__) . '<br><br>'; }
public function __construct() { $dir = PtcHandyMan::getDirs('files'); echo 'Class "' . __CLASS__ . '" autoloaded:<br> ' . $dir[__CLASS__] . '<br><br>'; }
public function __construct() { $dir = \PtcHandyMan::getDirs('directories'); echo 'Class "' . __CLASS__ . '" autoloaded, example with file name lowercase which is always the second guess for the autoloader: <br> ' . $dir[1] . ' - ' . basename(__FILE__) . '<br><br>'; }
public function __construct() { $dir = \PtcHandyMan::getDirs('files'); echo 'Class "' . __CLASS__ . '" autoloaded, namespace "' . __NAMESPACE__ . '":<br> ' . $dir[__CLASS__] . '<br><br>'; }