Re: [Coding Standards] Loading all files at once
| From: | Paul M Jones | Date: | Mon, 09 Jul 2007 20:59:25 +0000 |
| Subject: | Re: [Coding Standards] Loading all files at once | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-47305@lists.php.net to get a copy of this message | ||
On Jul 9, 2007, at 3:42 PM, Joshua Eichorn wrote:
Paul M Jones wrote:Exactly what problem are we trying to solve with this rule? What trouble is there with having includes in files? In particular, how does the "allfiles" solution help or hinder when trying to implement something like lazy-loading of plugins or adapters in a non-opcode-cache environment? As far as not being able to use an autoloader: to my knowledge, I have not yet run into a problem with including files as-needed with autoload, but then I may not have been paying close-enough attention. Can you help me with an example situation where autoloading fails with include? Regarding include_path, well, you've got me there. I am generally dependent on include_path and have found it to be quite helpful, but (as I've noted elsewhere) that may be because I insist on using only highly structured PEAR-style or Solar-style libraries that live in the PEAR directory. -- Paul M. Jones <http://paul-m-jones.com> Solar: Simple Object Library and Application Repository for PHP5. <http://solarphp.com> Join the Solar community wiki! <http://solarphp.org> Savant: The simple, elegant, and powerful solution for templates in PHP. <http://phpsavant.com>The proposed coding standard states:Having includes strewn throughout all your files allows gives us the current include_path mess and makes it impossible to use an autoloader if you want to. How do you propose we solve these problems if we don't drop the includes out of the files.Loading all files at once PEAR2/PackageName/allfiles.php is the "load all classes at once for easy startup and opcode caches friendliness" so that, for instance, the file might contain: <?php // note the lack of dependency on include_path - essential for beginners if (!class_exists(PEAR2_Exception)) {I don't think this should be a *requirement* at all. I agree that developers who *want* to provide this kind of functionality should abide by a standard way of doing it, but making it a requirement for each package seems like overkill to me (esp. for very large packages with adapters and plugin systems, like Text_Wiki and MDB2). I have heard the "it makes things easier for opcode caches" argument, but I don't find it especially strong. This seems very much like a "recipe" or "practice" candidate to me, not a coding standard by which package acceptance or denial will be judged.class PEAR2_Exception extends Exception {}} require dirname(__FILE__) . '/Base.php'; require dirname(__FILE__) . '/Exception.php'; require dirname(__FILE__) . '/Drivers/Common.php'; require dirname(__FILE__) . '/Drivers/Simple.php'; require dirname(__FILE__) . '/Drivers/Fancy.php'; ?>