ZF-11432: Provide a mechanism to load library code that works with filenames in the same way as classes are loaded.
Description
Hello.
If you have classes and a library of functions, you may file them in the same directory structure.
e.g.
For an abstract class called Util_TypedArray and its Util_TypedArray_Exception class:
/Util/TypedArray.php
/Util/TypedArray/Exception.php
For generic string and array function libraries:
/Util/Library/Array.php
/Util/Library/String.php
Internally, Zend_Loader converts Util_TypedArray into /Util/TypedArray.php.
My patch (http://framework.zend.com/code/diff.php/…&) exposes this conversion as a public static method.
This allows me to code something like this ...
<?php
// $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?
Regards,
Richard Quadling.
Comments
Posted by Richard Quadling (rquadling) on 2011-08-07T15:14:00.000+0000
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).