File: examples/autoload/example_locator_namespaces.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil  >  PHP Skeleton Framework  >  examples/autoload/example_locator_namespaces.php  >  Download  
File: examples/autoload/example_locator_namespaces.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 5 years ago
Size: 908 bytes
 

Contents

Class file image Download
<html>
<body>
<?php
include '../../A/Locator.php';

$path = dirname(__FILE__) . '/includes';
echo
"path=$path<br/>";

$locator = new A_Locator();
$locator->autoload();
echo
"A_Locator autoload()<br/>";

$locator->setDir($path, 'Foo');
echo
"A_Locator setDir() to load classes in namespace Foo_ or \\Foo\\ from $path/<br/>";

$regex = '/^Foo.*/';
$locator->setDir("$path/Foo", $regex);
echo
"A_Locator setDir() to load classes in matching regex '$regex' from $path/Foo/<br/>";

/*
$duration = new A_Datetime_Duration();
if ($duration) echo "A_Datetime_Duration autoloaded<br/>";
$bar = new Bar();
$foobar = new Foo_Bar();
*/

$classes = array('FooBar', 'Foo_Bar', '\Foo\BarNS', '\Foo\Bar\BazNS', );
foreach (
$classes as $class) {
    echo
"Instantiate $class<br/>";
   
$foobar = new $class();
    if (
class_exists($class)) {
        echo
"$class autoloaded<br/>";
    }
}
?>
</body>
</html>

For more information send a message to info at phpclasses dot org.