View Source

<p>In order to get the fastest possible loading of includes, you should ensure that in situations where you have multiple include paths, the paths are in the order of how many files you wish to include (most first).</p>

<p>In most Zend Framework applications, the majority of the included files will be classes from the Zend Framework library, and you should therefore ensure that the Zend Framework path is the first in your include path list.</p>

<p>To do this, add the path like so:</p>

<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
set_include_path($path . PATH_SEPARATOR . get_include_path());
]]></ac:plain-text-body></ac:macro>

<p>The reason for this is that when including files, PHP will look in each path for the file requested, in the order specified in the include path list. If 90% of your files are Zend Framework classes, but you've got a couple of other paths before the Zend Framework path, PHP will waste a lot of time looking in those first, for every Zend Framework class.</p>

<p>This can have a significant performance impact. I saw an improvement of ~32% (~120ms) by changing my include path from:</p>

<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
.;X:\Custom Library 1\;X:\Custom Library 2\;X:\Zend Framework
]]></ac:plain-text-body></ac:macro>

<p>To:</p>

<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
X:\Zend Framework;X:\Custom Library 1\;X:\Custom Library 2\;.
]]></ac:plain-text-body></ac:macro>

<p>The only downside of this is that files included from paths at the end of the list will take longer, but that's basically irrelevant, because something has to come last, so it may as well be the least used paths.</p>

<p>Of course, you should always try to keep your include path list as short as possible as well.</p>