Comments on: require(), require_once() and Dynamic Autoloading in PHP http://gen5.info/q/2009/01/09/an-awesome-autoloader-for-php/ Towards Intelligent Systems Wed, 11 Jul 2012 12:59:08 +0000 hourly 1 http://wordpress.org/?v=3.0.3 By: Paul Houle http://gen5.info/q/2009/01/09/an-awesome-autoloader-for-php/comment-page-1/#comment-4221 Paul Houle Tue, 10 Feb 2009 16:12:42 +0000 http://gen5.info/q/?p=137#comment-4221 Good catch @alecu, I fixed it! Good catch @alecu, I fixed it!

]]>
By: alecu http://gen5.info/q/2009/01/09/an-awesome-autoloader-for-php/comment-page-1/#comment-4219 alecu Tue, 10 Feb 2009 15:27:18 +0000 http://gen5.info/q/?p=137#comment-4219 02 for (int i=0;i<10;$i++) { 03 require "template-$i.php"; 04 } to cause the sequential execution of a namset of PHP files named “template-0.php” through “template-10.php.” You mean template-0 through template-9 :) 02 for (int i=0;i<10;$i++) {
03 require “template-$i.php”;
04 }
to cause the sequential execution of a namset of PHP files named “template-0.php” through “template-10.php.”

You mean template-0 through template-9 :)

]]>
By: Paul Houle http://gen5.info/q/2009/01/09/an-awesome-autoloader-for-php/comment-page-1/#comment-3107 Paul Houle Thu, 22 Jan 2009 20:16:56 +0000 http://gen5.info/q/?p=137#comment-3107 @Brown, you're right about the caching. My experience is that serialize() and unserialize() are pretty quick, but print_r() could also be used to generate a PHP include file thats initialize the data structure as well. If you're loading a small number of classes from a very large set, there will eventually be a crossover point where you're better off keeping the mapping in a persistent key/value store than loading the whole thing. It would be a fun bunch of experiments, but the performance is good enough for me right now. @Brown,

you’re right about the caching. My experience is that serialize() and unserialize() are pretty quick, but print_r() could also be used to generate a PHP include file thats initialize the data structure as well.

If you’re loading a small number of classes from a very large set, there will eventually be a crossover point where you’re better off keeping the mapping in a persistent key/value store than loading the whole thing.

It would be a fun bunch of experiments, but the performance is good enough for me right now.

]]>
By: A.J. Brown http://gen5.info/q/2009/01/09/an-awesome-autoloader-for-php/comment-page-1/#comment-3099 A.J. Brown Thu, 22 Jan 2009 18:59:00 +0000 http://gen5.info/q/?p=137#comment-3099 This is a great article, Thanks! One thing I'd like to reiterate is caching your class-to-file map if you're going to use an autoloader such as the one I proposed. I've found that in some of my largest applications, It can take as much as 4 seconds to scan all of the files and build the map. That's obviously not desirable. However, once the map is built and cached, it runs very quickly. Depending on your system, you might want to try caching with Memcached or sqlite vs serialization. I'd like to experiment with a sqlite adaptation and compare that with the cost of serialization. This is a great article, Thanks!

One thing I’d like to reiterate is caching your class-to-file map if you’re going to use an autoloader such as the one I proposed. I’ve found that in some of my largest applications, It can take as much as 4 seconds to scan all of the files and build the map. That’s obviously not desirable. However, once the map is built and cached, it runs very quickly.

Depending on your system, you might want to try caching with Memcached or sqlite vs serialization. I’d like to experiment with a sqlite adaptation and compare that with the cost of serialization.

]]>
By: Ivan http://gen5.info/q/2009/01/09/an-awesome-autoloader-for-php/comment-page-1/#comment-2482 Ivan Mon, 12 Jan 2009 18:26:53 +0000 http://gen5.info/q/?p=137#comment-2482 It might be too late for the php community, but it seems like Zend needs to move to some sort of module system. Autoloading just leaves the door open for crappy implementations and poorly thought out dependency schemes. It might be too late for the php community, but it seems like Zend needs to move to some sort of module system. Autoloading just leaves the door open for crappy implementations and poorly thought out dependency schemes.

]]>

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /hosting/sites/gen5.info/htdocs/q/wp-includes/class-snoopy.php on line 1148

Warning: fsockopen(): unable to connect to :80 (php_network_getaddresses: getaddrinfo failed: No address associated with hostname) in /hosting/sites/gen5.info/htdocs/q/wp-includes/class-snoopy.php on line 1148