ZF-11432: Provide a mechanism to load library code that works with filenames in the same way as classes are loaded.



If you have classes and a library of functions, you may file them in the same directory structure.


For an abstract class called Util_TypedArray and its Util_TypedArray_Exception class:


For generic string and array function libraries:


Internally, Zend_Loader converts Util_TypedArray into /Util/TypedArray.php.

My patch (…&) exposes this conversion as a public static method.

This allows me to code something like this ...

// $Id: arrayColumnExtract.php,v 1.0.4 2011-05-04T14:09:43+01:00 RichardQ $

require_once 'Zend/Loader/Autoloader.php';
$o_ZendLoaderAutoLoader = Zend_Loader_Autoloader::getInstance();

 * Include the Array library.
include_once Zend_Loader::standardiseFile('Util_Library_Array');}}

Allowing the same userland naming convention/structure of classes and libraries.

How do I get this code part of the next release?


Richard Quadling.


I'm wondering if the method should be called normaliseFile() (or normalizeFile() depending upon consensus).

With the various ongoing discussions on autoloading functions in the PHP Internals mailing list, a normalize method could be used for all things being autoloaded (interfaces, traits, classes and potentially functions, as well as libraries as I've demonstrated here).