Login   Register  
PHP Classes
elePHPant
Icontem

File: usage.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Bob Gombocki  >  Class Manager  >  usage.php  >  Download  
File: usage.php
Role: Example script
Content type: text/plain
Description: Use cases
Class: Class Manager
Auto-load classes based on XML definitions
Author: By
Last change: new feature: xml root
Date: 5 years ago
Size: 1,664 bytes
 

Contents

Class file image Download
<?php

//require_once('testclasses/lookeduprecursive/somedir/LookedupRecursive.php');
require_once('classmanager/ClassManager.php');

// loading default configuration (classpath.xml)
ClassManager::instance()->loadDefaultXml();

// using the classes right away
new TestClass1();
new 
TestClass2();
new 
TestClass3();
new 
LookedupClass();
new 
LookedupTemplate();
new 
LookedupRecursive();

// loading additional classes using XML
//ClassManager::instance()->loadXml('moreclasses.xml');

// its best to use relative paths in the classpath xmls, so it will be more independent from the concrete running environment. Those relative paths are relative to the currently running script. 
// it's possible to load an XML with a different "root" path that will be put in front of all the repository paths found in the XML file: 
// ClassManager::instance()->loadDefaultXml('c:/php/myclasses');
// ClassManager::instance()->loadXml('../..');

// loading additional class through interface
// ClassManager::instance()->addPath('MyNewClass', 'myClassDir/MyNewClass.php');

// adding additional auto lookup paths
ClassManager::instance()->addLookupPath('/php/myclasses/');

// adding additional auto lookup paths with custom file name template
ClassManager::instance()->addLookupPath('/php/myclassesTemplate/''{className}.class.php');

// testing file existence
ClassManager::instance()->checkFilesExist();

// forcing require on all specified class sources
ClassManager::instance()->requireAll();

// generate PHP code to add classpath
$phpCode ClassManager::instance()->generatePhpClassPathDump();



echo 
'Test successful'


?>