From: Gianluca S. <gi...@gm...> - 2010-08-29 10:49:08
|
On Sun, Aug 29, 2010 at 10:25 AM, David Hicks <hic...@op...> wrote: > On Sun, 2010-08-29 at 10:06 +0200, Gianluca Sforna wrote: >> how exactly require_api calls are better than the standard "require_once"? > > require_once() uses the library path environment variable to search for > a file in each of the library paths. This process requires a bunch of > stat calls to the file system that can be quite expensive. > > I gather newer versions of PHP have improved handling of require_* calls > so the performance differences probably aren't noticeable. > > What require_api does do is ensure that there aren't any file naming > collisions between the different library paths used by MantisBT. We have > a relocatable 'core' directory, 'plugin' directory, 'lang' directory, > etc that could be hosted in completely different locations on the disk. > By calling require_api we can ensure that PHP is only looking in one > known location rather than attempting to search through multiple paths > to find the file (that could be the wrong one in case of naming > collisions). Thanks David, at least now I know why we have this stuff :) > > Use of require/require_once/etc is far inferior to using __autoload. If > MantisBT moves towards a more OO code style, __autoload can then be used > to increase performance by a significant factor. Uhm. I thought the two mechanisms were not alternative. I see a lot of "require_once" in the Zend Framerwork class hierarchy, do know why this apparent contradiction exists? -- Gianluca Sforna http://morefedora.blogspot.com http://www.linkedin.com/in/gianlucasforna |