On 22 March 2010 14:51, Robert P. J. Day <rpjday@xxxxxxxxxxxxxx> wrote: > On Mon, 22 Mar 2010, Richard Quadling wrote: > >> Depending upon what is being included, an autoloader could help >> here. >> >> The main payoffs for autoloading are reduced memory footprint (class >> are loaded JIT) and no need for each class to know exactly where the >> other classes are. >> >> So, your main page needs to load the autoloader and the autoloader >> handles the loading of the classes. >> >> No need to change the include_path setting. > > ok, i'm looking at the PHP manual page for autoload, sample: > > function __autoload($class_name) > { > require_once $class_name . '.php'; > } > > and some obvious questions suggest themselves: > > 1) in as simple an example as above, does the include_path still > control the search? since i'm not doing anything fancy above in terms > of specifying *where* that class is defined, it seems that i'll still > have the same problem to solve, no? No. The autoloader is part of the project, so it will know its relative pathing to the other files. __DIR__ in the autoloader will tell the autoloader where it is and all associated files should be relative this. You only need to know the relative path of the autoloader. No need to alter include_path and you can remove all those (require|include)(_once)? lines too as the autoloader kicks in whenever a class it requested that hasn't been loaded. > > 2) i'm guessing that i can make the __autoload function as > sophisticated as i want, in that i can have it consult an environment > variable to determine where to search, but i'm still unsure as to how > i can set an environment variable to be consulted on the "server" > side. I think once you've got the autoloader working, you don't need to worry. > rday > -- > > ======================================================================== > Robert P. J. Day Waterloo, Ontario, CANADA > > Linux Consulting, Training and Kernel Pedantry. > > Web page: http://crashcourse.ca > Twitter: http://twitter.com/rpjday > ======================================================================== > -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php