Winfield Trail
Winfield Trail

Reputation: 5695

PHP script: How big is too big?

I'm developing a webapp in PHP, and the core library is 94kb in size at this point. While I think I'm safe for now, how big is too big? Is there a point where the script's size becomes an issue, and if so can this be ameliorated by splitting the script into multiple libraries?

I'm using PHP 5.3 and Ubuntu 10.04 32bit in my server environment, if that makes any difference.

I've googled the issue, and everything I can find pertains to PHP upload size only.

Thanks!


Edit: To clarify, the 94kb file is a single file that contains all my data access and business logic, and a small amount of UI code that I have yet to extract to its own file.

Upvotes: 2

Views: 1000

Answers (2)

JohnP
JohnP

Reputation: 50029

Do you mean you have 1 file that is 94KB in size or that your whole library is 94KB in?

Regardless, as long as you aren't piling everything into one file and you're organizing your library into different files your file size should remain manageable.

If a single PHP file is starting to hit a few hundred KB, you have to think about why that file is getting so big and refactor the code to make sure that everything is logically organized.

Upvotes: 4

taxilian
taxilian

Reputation: 14324

I've used PHP applications that probably included several megabytes worth of code; the main thing if you have big programs is to use a code caching tool such as APC on your production server. That will cache the compiled (to byte code) PHP code so that it doesn't have to process every file for every page request and will dramatically speed up your code.

Upvotes: 2

Related Questions