简体   繁体   English

PHP脚本:太大太大了?

[英]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. 我正在用PHP开发一个Webapp,此时核心库的大小为94kb。 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. 我在服务器环境中使用PHP 5.3和Ubuntu 10.04 32bit(如果有任何区别)。

I've googled the issue, and everything I can find pertains to PHP upload size only. 我已经搜索了这个问题,发现的所有内容仅与PHP上传大小有关。

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. 编辑:明确地说,94kb文件是一个文件,其中包含我所有的数据访问和业务逻辑以及少量尚未提取到其自己文件的UI代码。

Do you mean you have 1 file that is 94KB in size or that your whole library is 94KB in? 您是说您有一个大小为94KB的文件,或者您的整个库为94KB?

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. 如果单个PHP文件开始达到数百KB,则必须考虑该文件为何变得如此之大,然后重构代码以确保所有内容都在逻辑上进行组织。

I've used PHP applications that probably included several megabytes worth of code; 我使用了可能包含几兆字节代码的PHP应用程序。 the main thing if you have big programs is to use a code caching tool such as APC on your production server. 如果您有大型程序,最主要的事情就是在生产服务器上使用诸如APC之类的代码缓存工具 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. 这将缓存已编译的(按字节编码)PHP代码,这样就不必为每个页面请求都处理每个文件,并且可以大大加快代码的速度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM