Re: [RFC] Function autoloading through spl_autoload

From: Date: Sun, 14 Aug 2011 22:11:07 +0000
Subject: Re: [RFC] Function autoloading through spl_autoload
Groups: php.internals 
Request: Send a blank email to internals+get-54601@lists.php.net to get a copy of this message
Instead of trying to figure out how to autoload functions and cover all your bases, how about simply adding a __call() magic method? That way, each application (or framework) can make their own decisions about what they're going to autoload and how. A much simpler solution, and one with more potential uses than just autoloading. The __call() method could be invoked first in the current namespace, if present - then in the parent namespace, if present, etc. up to the global namespace. Since functions are no longer just global, but can now exist in a namespace, it is likely you're going to need a different "autoloader" or other dynamic function resolvers in each namespace, since we tend to create a namespace for classes/functions designed to perform a specific kind of task - for example, a template/view-engine probably needs to autoload display-formatting functions, while a controller/dispatcher might need to autoload action-filters, etc. Just a thought :-) / Rasmus Schultz

« previous php.internals (#54601) next »