Know: thinkphp compiled cache file ~runtime.php

Source: Internet
Author: User
1. Defining a single entry file (index.php)

When these two items are not defined in a single-entry index.php, a compiled cache file is generated ~runtime.php

Define (' Runtime_path ', './app/temp/');    Define compilation directory define (' App_debug ', TRUE);           Turn on debug mode

The above two lines cannot function in index.php, then index.php becomes

1 
 
  

2. Generate a compilation cache file (~runtime.php)

3. Copy all the contents of the ~runtime.php into the index.php, and the effect will be the same as before.

The compiled content cached in ~runtime.php is equivalent to integrating all index.php boot operations into the ~runtime.php file.

With this cached compilation file, index.php will not boot again at the next run, but instead directly detects if there is a ~runtime.php compiled cache file, and if so, runs ~runtime.php directly.

Other explanations (from here)

The project compilation mechanism refers to the kernel cache file ~runtime.php and the project compile cache file ~app.php are automatically generated when the system is first run.
These compiled cache files package the core and project necessary files into a file, and remove all whitespace and comment code, because there is a precompiled process, so there are some related directory detection, for the non-existent directory can be automatically generated, the automatic generation mechanism will be mentioned later.
When executed the second time, the compiled cache file is loaded directly, which saves a lot of IO overhead and speeds up execution. The project compilation mechanism has no effect on the operation, and the precompilation and other directory detection mechanisms execute only once, so no matter how many complex operations are done during the precompilation process, there is no efficiency missing for subsequent executions.
The files contained in the ~runtime.php are determined by the system's core.php file, which is determined by the schema extension entry file if the schema extension is used. The following files are included in the default core mode: System Definition file defines.php, System function library functions.php, System base class think, exception base class Thinkexception, log class log, application class app, controller base class Action, view Class View.
Other class libraries can be loaded using the system import mechanism or the automatic loading mechanism in the action method.
~app.php usually contains some of the following files: project configuration file (consolidated by custom configuration, project configuration), project common function file common.php. Each project can also add its own list of project compilation files separately, simply define the app.php file under the project configuration directory and return an array of file lists that need to be added to the project's compilation cache.

"Settings in Portal file index.php"
Compiling the cache file, the default is automatically generated under the project directory under the runtime directory. 、
Define (' Runtime_path ', './myapp/temp/'); If you want to set your own directory, you can set runtime_path in the portal file to make changes
Note under the Linux environment, you need to set writable permissions on the Runtime_path directory.

Note The project compilation cache is not generated under debug mode, but the core cache is still generated
Define (' No_cache_runtime ', True); If you do not want to generate core cache files
Define (' Strip_runtime_space ', false); Sets whether the contents of the compiled cache are left blank and commented
The generated compilation cache file is not commented out and blank, just to merge the files together, the benefit is easy to debug the wrong location, it is recommended to deploy the mode when the above set to TRUE or delete the definition.

  • 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.