Understanding: compiling cache files for ThinkPHP ~ Runtime. php

Source: Internet
Author: User
Understanding: compiling cache files for ThinkPHP ~ Runtime. php 1. define a single entry File (index. php)

If you do not define these two items in index. php at the single portal, a compilation cache file will be generated ~ Runtime. php

Define ('runtime _ path', './App/Temp/'); // define the compiling directory define ('app _ debug', TRUE); // enable the debugging mode

If the preceding two rows cannot be used in index. php, index. php becomes

1
 

2. Generate the compilation cache file (~ Runtime. php)

3. copy ~ All content in runtime. php is included in index. php, and the running effect will be the same as before.

~ The compiled content cached in runtime. php is equivalent to integrating all the operations guided by index. php ~ In the runtime. php file.

With this cached compilation file, index. php does not boot at the next runtime, but directly checks whether the file exists ~ Runtime. php compiles the cache file. If yes, it runs directly ~ Runtime. php.

Other details (from here)

The project compilation mechanism means that the system automatically generates core cache files when it runs for the first time ~ Runtime. php and project compilation cache files ~ App. php.
These compilation cache files package the files necessary for the core and project into one file, and remove all spaces and comment on the code, because there is a pre-compilation process, therefore, some related directory detection will be performed, and non-existing directories can be automatically generated. this automatic generation mechanism will be mentioned later.
During the second execution, the compiled cache files are directly loaded, saving a lot of IO overhead and speeding up execution. The project compilation mechanism has no impact on the operation. the pre-compilation operation and other directory detection mechanisms only execute once. therefore, no matter how many complex operations are performed during the pre-compilation process, there is no lack of efficiency for subsequent execution.
~ The file contained in runtime. php is determined by the system's core. php file. If mode extension is adopted, it is determined by the mode extension entry file. The default core mode contains the following files: 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 or automatic loading mechanism in the operation method.
~ App. php usually contains the following files: The project configuration file (composed of convention configuration and project configuration) and the project public function file common. php. Each project can also add its own project compilation file list. you only need to define the app. php file under the project configuration directory and return an array of files that need to be added to the project compilation cache.

[Set in index. php of the entry file]
Compile the cache file. by default, it is automatically generated under the Runtime directory under the Project Directory. ,
Define ('runtime _ path', './MyApp/temp/'); // If you want to set your own directory, you can set RUNTIME_PATH in the file to change
Note that you need to set the writable permission for the RUNTIME_PATH directory in the Linux environment.

Note that the project compilation cache will not be generated in the debugging mode, but the core cache will still be generated.
Define ('no _ CACHE_RUNTIME ', True); // If you do not want to generate a core cache file
Define ('strip _ RUNTIME_SPACE ', false); // you can specify whether to empty and comment the compiled cache content.
The generated compilation cache files are not commented out and blank. they are only merged together. This facilitates debugging error locating, we recommend that you set the preceding setting to True or delete this definition when deploying the deployment mode.

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.