Is it necessary for PHP to merge multiple PHP files with as few require as possible?

Source: Internet
Author: User
Tags apc
For example, the template file contains a header. php, footer. php, widget. php and so on. These are all require to main. php, is it necessary to merge all these files into a whole file? What if xcacheorAPCoraccelerater is loaded? Thank you for your answers... for example, the template file contains a header. php, footer. php, widget. php and so on. These are all require to main. php, is it necessary to merge all these files into a whole file? What if xcache or APC or accelerater is loaded?

Thank you for your answers. To add this question, do I mean it is necessary to generate the final template cache file like thinkphp? If necessary, is there a class that generates the final PHP file based on the detected require sequence for multiple PHP files? Thanks

Reply content:

For example, the template file contains a header. php, footer. php, widget. php and so on. These are all require to main. php, is it necessary to merge all these files into a whole file? What if xcache or APC or accelerater is loaded?

Thank you for your answers. To add this question, do I mean it is necessary to generate the final template cache file like thinkphp? If necessary, is there a class that generates the final PHP file based on the detected require sequence for multiple PHP files? Thanks

Multiple files help to properly organize the code structure and improve the readability and maintainability of the Code.

Compared with several IO overhead, it is obvious that readability and maintainability are much more important in the actual production environment.

The Business Code layer is not recommended or necessary.
The view template code is automatically merged by the modern framework to generate a cache in the production environment, and there is no need to manually merge the view template code.

Data caching at the Memcache/Redis level is not discussed in this issue.

If you want to solve such problems in the project, this project cannot be implemented at all.

The production environment uses tools such as APC to directly Load Code into memory.

Now we have apc/opcache, so you don't have to worry about require.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.