thinkphp3.2 The Lite file to replace the frame entry file or apply the entry file Method _php Tutorial

Source: Internet
Author: User
Tags constant definition php definition

How to replace a frame entry file or apply a portal file in the thinkphp3.2 Lite file


The examples in this article describe how to replace a frame entry file or apply a portal file to a lite file in thinkphp3.2. Share to everyone for your reference. The specific analysis is as follows:

Version 3.2 supports the creation of lite files based on the current operating environment, which can be used to replace the portal files of the framework or application portal files to improve operational efficiency.

Our recommendation is to generate a lite file after you turn off debug mode in a production environment.

Note that the current SAE platform does not support direct generation of lite files.

Generate Lite Files

To generate a lite file, you need to add a constant definition to the portal file:

The code is as follows:

Define (' Build_lite_file ', true);

By default, a lite.php file is generated under the runtime directory after running again.

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

The code is as follows:

' Runtime_lite_file ' = app_path. ' lite.php '

After configuration, the location of the generated lite file is App_path. ' lite.php '.

The content of the compilation file of the Lite file is the system default, if you want to change or add other compiled files, you can define the compilation list file externally, for example: we add the lite.php definition below the application configuration directory as follows:

?

1

2

3

4

5

6

7

8

9

Ten

One

+

All

+

+

/

/

Return Array (

Think_path. ' common/functions.php ',

common_path. ' common/function.php ', /p>

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 are included in the compilation cache of the Lite file. You can also make changes to the generated lite file.

If you modify the framework file and apply functions and configuration files, you need to delete the Lite file regeneration.

Because the SAE and other cloud platforms do not support file writing, direct generation of lite files is not supported.

Replacement entry

The Lite file can be used to replace the frame entry file or the application portal file.

Replace Frame entry file

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

The code is as follows:

Require './thinkphp/thinkphp.php ';

Change to:

The code is as follows:

Require './runtime/lite.php ';

After you replace the Lite file, the application compilation cache is no longer required.

Replace the app portal file

If your portal file has no other code and logic, you can also access the lite.php file directly as the application's entry file. Copy the lite.php file to the same directory as the application portal file and rename it to index.php as normal access (the original application portal file can be backed up for use when regenerating the Lite file).

Note: If your environment or directory location changes, as well as changes to the core framework and application functions, configuration and other files, you will need to regenerate the lite file.

It is hoped that this article will be helpful to everyone's PHP programming based on thinkphp framework.

http://www.bkjia.com/PHPjc/1003826.html www.bkjia.com true http://www.bkjia.com/PHPjc/1003826.html techarticle thinkphp3.2 in the Lite file to replace the frame entry file or the application entry file method This article describes the thinkphp3.2 in the Lite file replacement framework portal file or application of the portal file method. Points ...

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