Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I improve the performance of 'include()s' in PHP?

I have a 1.9MB PHP library that I am including at the beginning of my scripts. It contains all of my database objects, methods, etc necessary for my website. It takes 0.1s to 0.3s to include it each time.

I use eAccelerator to cache the bytecode of this file. What else can I do to optimize the performance of this 'include'?

like image 901
Kevin Owocki Avatar asked Nov 28 '09 23:11

Kevin Owocki


1 Answers

Split it into modules and load the chunks only when needed. I think that is the only way to really improve performance, I have been in the same situation and only that solved it. It's a lot of code to include, in my mind too much. I'll bet you a beer that you do not need all 1.9MB of code in every context.

like image 187
Pekka Avatar answered Oct 20 '22 00:10

Pekka