Kevin Owocki
Kevin Owocki

Reputation: 1418

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'?

Upvotes: 5

Views: 1255

Answers (1)

Pekka
Pekka

Reputation: 449435

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.

Upvotes: 8

Related Questions