Reduce the number of included files

My Zend Framework and Doctrine-based application includes> 300 files for each request. These are basically the same files.

This is a pretty big overhead. Partially allowed by Zend_Cache (and Memcache), but not all pages can be cached.

  • How to reduce this number? How to speed up?

Doctrine has the option to compile the necessary files , which seems quite rational for the production server and the final version of the application.

My plan is to compile other libraries (I already shared all require_once ).

  • Are there any tools for this task? Maybe some cache drivers do this automatically? How to set them up?
+4
source share
2 answers

The best option is to use APC or Zend_Accelerator. But still, you can make these "compilation" scripts that combine classes together into a single file. This reduces the required IO to a minimum. Unfortunately, you also need to rewrite the startup process so that it looks at the corresponding file. You can usually combine common classes (Zend_Form + Elements + Decorators, commonly used validators, Request + Response + Router + Controller, Zend_Db + adapters + Zend_Db_Select, etc.). Basically, classes always used for each request can be easily compressed and manually included in one file. The best way is to add a debugging call that will save all the included files ( http://www.php.net/get_included_files ) in the database, and then:

 SELECT * FROM files GROUP BY filename WHERE COUNT(filename) = $numOfRequests 

All files as a result can be safely combined into one file and included before downloading :)

+1
source

The overhead of including php files can usually be attributed to the opcode cache, such as APC , an extension available through pecl. Operation cache codes usually work by caching the compiled bytecode, so that the overhead of reading and analyzing the source code only occurs on the first request. This strongly denies the need or benefit of any source code compilation in your php files.

+2
source

All Articles