01-17-2009, 10:44 AM
|
#3 (permalink)
|
|
The Contributor
Join Date: Jan 2008
Location: England, UK
Posts: 83
Thanks: 3
|
That's fine. I've just thought of something though - are we planning to take advantage of PHP5's class/interface autoloading? What is the minimum version of PHP we are supporting anyway (at least 5.1 I'd have thought).
Anyway, I was writing an autoload function to use the class/interface.name.php - can you see what's wrong below?
PHP Code:
/* snip: Phlox_Registry */
/**
* Class/interface autoloader
* @param string $name Name of the class or interface
* @throws Exception if unable to load the class/interface
*/
public static function autoload($name)
{
require_once APPLICATION_PATH . '/core/' . strtolower(str_replace('_', '.', $name)) . '.php';
if (!class_exists($name, false) || !interface_exists($name, false))
{
throw new Exception("Unable to load the class or interface '$name'.");
}
}
/* snip: Phlox_Registry */
$class = new ClassName(); // should be in /core/class.classname.php
$interface = new InterfaceName(); // should be in /core/interface.interfacename.php
If we keep 'class' or 'interface' in the name of the file we're going to have a hard job including them unless we make the classnames something like: class Class_ClassName and interface Interface_InterfaceName.
I'm actually thinking a better method could be to stip out the class/interface part of the filename altogether now.
|
|
|
|