Method for replacing the framework entry file or application entry file with the Lite File in thinkphp3.2 _ php instance

Source: Internet
Author: User
Tags constant definition
This article mainly introduces how to replace the framework entry file or application entry file with the Lite File in thinkphp3.2, involving ThinkPHP-related configuration skills, for more information about how to replace the framework entry file or application entry file in thinkphp3.2, see the following example. Share it with you for your reference. The specific analysis is as follows:

Version 3.2 allows you to generate Lite files based on the current running environment. you can replace the framework entry files or application entry files to improve the running efficiency.

We recommend that you disable debugging mode in the production environment and generate Lite files.

Note: Currently, the SAE platform does not support generating Lite files directly.

Generate Lite files

To generate a Lite file, you must add a constant definition to the entry file:

The code is as follows:

Define ('build _ LITE_FILE ', true );

By default, a lite. php file is generated under the Runtime directory after the program is run again.

If you need to modify the location or name of the Lite file, you can add the following configuration in the application configuration file:

The code is as follows:

'Runtime _ LITE_FILE '=> APP_PATH. 'lite. php'

After configuration, the generated Lite File is located at APP_PATH. 'lite. php '.

The content of the Lite File is the system default. if you want to change or add other compilation files, you can define the compilation list file in the external environment, for example: we add lite under the application configuration directory. php is defined as follows:

return array(  THINK_PATH.'Common/functions.php',  COMMON_PATH.'Common/function.php',  CORE_PATH . 'Think'.EXT,  CORE_PATH . 'Hook'.EXT,  CORE_PATH . 'App'.EXT,  CORE_PATH . 'Dispatcher'.EXT,  CORE_PATH . 'Model'.EXT,  CORE_PATH . 'Log'.EXT,  CORE_PATH . 'Log/Driver/File'.EXT,  CORE_PATH . 'Route'.EXT,  CORE_PATH . 'Controller'.EXT,  CORE_PATH . 'View'.EXT,  CORE_PATH . 'Storage'.EXT,  CORE_PATH . 'Storage/Driver/File'.EXT,  CORE_PATH . 'Exception'.EXT,  BEHAVIOR_PATH . 'ParseTemplateBehavior'.EXT,  BEHAVIOR_PATH . 'ContentReplaceBehavior'.EXT,);

All files defined in the lite. php file will be included in the compilation cache of the Lite File. You can also modify the generated lite File.

If you modify the framework file, application function, and configuration file, you need to delete the Lite File and regenerate it.

Because cloud platforms such as SAE do not support file writing, Lite files cannot be generated directly.

Replacement entry

Lite files can be used to replace the framework entry file or application entry file.

Replace the framework entry file

After the Lite File is generated, you can modify the framework entry file in the original application entry file as follows:

The code is as follows:

Require './ThinkPHP. php ';


Changed:

The code is as follows:

Require './Runtime/lite. php ';

After the Lite File is replaced, the application compilation cache is no longer needed.

Replace the application entry file

If your entry file does not have any other code or logic, you can directly access the lite. php file as the entry file of the application. Put lite. copy the php file to the same directory of the application entry file and change it to index. php can be accessed as usual (the original application entry file can be backed up for use when the Lite File is regenerated ).

Note: If your environment or directory location changes, and you have changed the core framework, application functions, configurations, and other files, you need to regenerate the Lite File.

I hope this article will help you with ThinkPHP framework-based php programming.

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.