Issues

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

Issue Type: Improvement Created: 2011-06-03T11:56:16.000+0000 Last Updated: 2011-08-07T15:14:00.000+0000 Status: Open Fix version(s): Reporter: Richard Quadling (rquadling) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Loader

Related issues: Attachments:

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:

<pre class="highlight">
/Util/TypedArray.php
/Util/TypedArray/Exception.php

For generic string and array function libraries:

<pre class="highlight">
/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 ...

<pre class="highlight">
<?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).

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts