Most efficient way to package php API
<p>I am writing a small api that will involve a number of "commands" with common elements, which involve reading parameters POST'ed to the script(s) and acted upon accordingly</p>

<p>I would like to have the most optimum execution, and am not sure if it's better to have one largish script that switches on a $cmd variable, or to have each command in it's own script.</p>

<p>it all really depends on how php handles script execution. if for example, the script is parsed and tokenized each time on the fly, it would be better to have a lot of short scripts that don't have redundant code being loaded and parsed/tokenized each time.</p>

<p>if however php reads,parses and tokenizes the scripts, and caches the "instructions" in memory, only re-loading/parsing/tokenizeing when the script has actually been edited (eg based on filedate), it would be better to have it all in one script, as then the code could be factorized into functions, and would be easier to maintain, as there would be no repeated code. i don't like the idea of including common files, if that inclusion invokes a reparse each time.</p>

<p>hopefully this question is not to generic in nature - i see no need to give sample code as i am really just wanting to know the best way to "package" my api </p>
