/* 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>&nbsp;&nbsp;' . $dir[1] . ' - ' . basename(__FILE__) . '<br><br>';
 }
 public function __construct()
 {
     $dir = \PtcHandyMan::getDirs('ns');
     echo 'Class "' . __CLASS__ . '" autoloaded, namespace "' . __NAMESPACE__ . '" example: <br>&nbsp;&nbsp;' . $dir[__NAMESPACE__] . ' - ' . basename(__FILE__) . '<br><br>';
 }
<?php

/* 
 * EXAMPLE FILE FOR HELPER FUNCTIONS FOR THE LIBRARY COMPONENTS
 * ALL EXAMPLES HAVE BEEN TAKEN FROM THE COMPONENTS EXAMPLE FILES
 * PTCHM.PHP, PTCDEBUG.PHP AND THE AUTOLOADER EXAMPLE FILES FOLDER 
 * ARE REQUIRED FOR THESE EXAMPLES
 */
session_start();
// start session for persistent debugging and code highlighter popup
require_once '../PtcHm.php';
// require the handyman component
declare (ticks=1);
// declare globally for the code coverage and function calls trace
/* REGISTER THE AUTOLOADER */
PtcHandyMan::register();
// will auto include the ptc-helpers.php file and all other classes
/* START THE DEBUGGER & LOGGER COMPONENT */
$_GET['debug'] = true;
// turn on the debug
//$_GET['debug_off']=true;    		// turn off debug
$options = array('url_key' => 'debug', 'url_pass' => 'true', 'die_on_error' => false, 'exclude_categories' => null);
PtcDebug::load($options);
// initialize the class
/*** PTC DEBUGGER & LOGGER HELPERPS ****************************************************/
/* START CODE COVERAGE ANALYSIS TO CHECK WHICH LINES HAVE BEEN EXECUTED */
ptc_start_coverage();
// PtcDebug::startCoverage( )
/* START FUNCTION CALLS TRACING  */
ptc_start_trace();
// PtcDebug::startTrace( )
 public function __construct()
 {
     $dir = PtcHandyMan::getDirs('directories');
     echo 'Class "' . __CLASS__ . '" autoloaded from directory by replacing "_" with "-" separator:<br>&nbsp;&nbsp;' . $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>&nbsp;&nbsp;' . $dir[2] . ' - ' . basename(__FILE__) . '<br><br>';
 }
 public function __construct()
 {
     $dir = PtcHandyMan::getDirs('files');
     echo 'Class "' . __CLASS__ . '" autoloaded:<br>&nbsp;&nbsp;' . $dir[__CLASS__] . '<br><br>';
 }
예제 #8
0
 /**
  * Application bootstrap configuration
  */
 protected static function _setAppConfig()
 {
     /* paths */
     static::option('paths', Module::merge(ptc_path('root') . '/app/config/paths.php'));
     ptc_add_path(ptc_array_get(static::$_config, 'paths'));
     /* application */
     static::option('app', Module::merge(ptc_path('root') . '/app/config/app.php'));
     HandyMan::addAlias(ptc_array_get(static::$_config, 'app.aliases'));
     if ($locale = ptc_array_get(static::$_config, 'app.locale')) {
         setlocale(LC_ALL, $locale . 'UTF-8');
     }
     if ($timezone = ptc_array_get(static::$_config, 'app.timezone')) {
         date_default_timezone_set($timezone);
     }
     ptc_add_file(ptc_array_get(static::$_config, 'app.files'));
     ptc_add_dir(ptc_array_get(static::$_config, 'app.directories'));
     ptc_add_dir(ptc_array_get(static::$_config, 'app.namespaces'));
     if ($sep = ptc_array_get(static::$_config, 'app.separators')) {
         HandyMan::addSeparators($sep);
     }
     if ($conv = ptc_array_get(static::$_config, 'app.conventions')) {
         HandyMan::addConventions($conv);
     }
     /* database */
     static::option('db', Module::merge(ptc_path('root') . '/app/config/db.php'));
     if ($db = ptc_array_get(static::$_config, 'db')) {
         $loop = static::option('app.test_env') ? $db['develop'] : $db['prod'];
         foreach ($loop as $k => $v) {
             if (ptc_array_get($v, 'user')) {
                 DB::add($v, $k);
             }
         }
     }
     /* auth */
     static::option('auth', Module::merge(ptc_path('root') . '/app/config/auth.php'));
 }
 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>&nbsp;&nbsp;' . $dir[1] . ' - ' . basename(__FILE__) . '<br><br>';
 }
 public function __construct()
 {
     $dir = \PtcHandyMan::getDirs('files');
     echo 'Class "' . __CLASS__ . '" autoloaded, namespace "' . __NAMESPACE__ . '":<br>&nbsp;&nbsp;' . $dir[__CLASS__] . '<br><br>';
 }