ZF2 Autoloaders backported to ZF1

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ZF2 Autoloaders backported to ZF1

weierophinney
Administrator
Hey, all --

I finished backporting the ZF2 autoloaders to ZF1. Since these were all
named differently, there are no conflicts.

The question I have at this point is: should Zend_Application utilize
the AutoloaderFactory (and thus new autoloaders) by default? I've looked
into this briefly, and unfortunately, I don't see a way to do it
cleanly:

 * Zend_Loader_Autoloader's singleton instance is retrieved and assigned
   to the _autoloader property in the constructor.

 * The various autoloader options that Zend_Application is currently
   aware of are all specific to Zend_Loader_Autoloader. (That said, many
   of these could be adapted to the StandardAutoloader easily.)

As I alluded in the last point, the new StandardAutoloader
implementation can largely replace Zend_Loader_Autoloader in terms of
functionality.

One possibility I considered was to alter Zend_Application to allow
specifying via the constructor to use the AutoloaderFactory, which would
then call AutoloaderFactory::factory() within the constructor (to ensure
that ZF classes can be located). New configuration keys would allow
configuring the autoloader further. Since this would be opt-in, it's
would mean no BC break for developers upgrading from 1.11, but provide a
nice opt-in approach (which we could document) for specifying additional
autoloading strategies.

It'd look something like this:

    $application = new Zend_Application(
        APPLICATION_ENV,
        APPLICATION_PATH . '/configs/application.ini',
        true, // use AutoloaderFactory
    );

or maybe with a constant:

    $application = new Zend_Application(
        APPLICATION_ENV,
        APPLICATION_PATH . '/configs/application.ini',
        Zend_Application::USE_AUTOLOADER_FACTORY, // use AutoloaderFactory
    );

Configuration would look something like:

    autoloader-factory.Zend_Loader_ClassMapAutoloader[] = "path/to/classmap"
    autoloader-factory.Zend_Loader_StandardAutoloader.prefixes.My = "path/to/My"
    autoloader-factory.Zend_Loader_StandardAutoloader.namespaces.Your = "path/to/Your"
    autoloader-factory.Zend_Loader_StandardAutoloader.fallback_autoloader = false

and would be handled within the Application instance.

Thoughts?

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
Reply | Threaded
Open this post in threaded view
|

Re: ZF2 Autoloaders backported to ZF1

Wil Moore III
One possibility I considered was to alter Zend_Application to allow specifying via the constructor to use the AutoloaderFactory...no BC break for developers upgrading from 1.11, but provide a
nice opt-in approach (which we could document) for specifying additional
autoloading strategies.

+1
 
 or maybe with a constant:

   $application = new Zend_Application(
       APPLICATION_ENV,
       APPLICATION_PATH . '/configs/application.ini',
       Zend_Application::USE_AUTOLOADER_FACTORY, // use AutoloaderFactory
   );

+1 for using constants for better clarification (would love to see this more throughout the framework). 

Configuration would look something like:

   autoloader-factory.Zend_Loader_ClassMapAutoloader[] = "path/to/classmap"
   autoloader-factory.Zend_Loader_StandardAutoloader.prefixes.My = "path/to/My"
   autoloader-factory.Zend_Loader_StandardAutoloader.namespaces.Your = "path/to/Your"
   autoloader-factory.Zend_Loader_StandardAutoloader.fallback_autoloader = false

+1 
--
Wil Moore III

Best Practices for Working with Open-Source Developers
http://www.faqs.org/docs/artu/ch19s02.html

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html

DO NOT TOP-POST and DO trim your replies:
http://linux.sgms-centre.com/misc/netiquette.php#toppost