Re: alternative to allfiles.php, comments?
| From: | Paul M Jones | Date: | Mon, 27 Aug 2007 12:41:54 +0000 |
| Subject: | Re: alternative to allfiles.php, comments? | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-47863@lists.php.net to get a copy of this message | ||
On Aug 26, 2007, at 9:46 PM, Gregory Beaver wrote:
Hi all, Another possible solution to the "make it easy for beginners" problem would be to offer this syntax: <?php require '/full/path/to/PEAR2/PackageName.php'; PEAR2::PackageName::beginnerSetup(); ?> the beginnerSetup() static method would do what allfiles.php does in the current proposal. If we have auto-generated allfiles.php, it would be possible for beginnerSetup() to simply be: static function beginnerSetup() {While I am (still) not convinced that allfiles.php is a good idea, there is a related implementation in PHP Doctrine under a static method called "compile()". You can read about it here: <http://www.phpdoctrine.net/doctrine/manual/new/?chapter=getting-started#compiling> Quoting that page:require dirname(__FILE__) . '/PackageName/allfiles.php';} This should be a more intuitive solution for beginners. Comments?
Doctrine is quite big framework and usually dozens of files are being included on each request. This brings a lot of overhead. In fact these file operations are as time consuming as sending multiple queries to database server. The clean separation of class per file works well in developing environment, however when project goes commercial distribution the speed overcomes the clean separation of class per file -convention. Doctrine offers method called compile() to solve this issue. The compile method makes a single file of most used Doctrine components which can then be included on top of your script. By default the file is created into Doctrine root by the name Doctrine.compiled.php. Compiling is a method for making a single file of most used doctrine runtime components including the compiled file instead of multiple files (in worst cases dozens of files) can improve performance by an order of magnitude. In cases where this might fail, a Doctrine_Exception is throw detailing the error. <?php Doctrine::compile(); // on some other script: require_once('path_to_doctrine/Doctrine.compiled.php'); ?>-- 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>