thinkphp3.2中Lite文件替换框架入口文件或应用入口文件的方法
thinkphp3.2中Lite文件替换框架入口文件或应用入口文件的方法
本文实例讲述了thinkphp3.2中Lite文件替换框架入口文件或应用入口文件的方法。分享给大家供大家参考。具体分析如下:
3.2版本支持根据当前的运行环境生成Lite文件,可以替换框架的入口文件或者应用入口文件,提高运行效率。
我们的建议是在生产环境中关闭调试模式后生成Lite文件。
注意,目前SAE平台不支持直接生成Lite文件。
生成Lite文件
要生成Lite文件,需要在入口文件中增加常量定义:
代码如下:
define('BUILD_LITE_FILE',true);
默认情况下,再次运行后会在Runtime目录下面生成一个lite.php文件。
如果你需要修改Lite文件的位置或者名称,可以在应用配置文件中增加配置如下:
代码如下:
'RUNTIME_LITE_FILE'=> APP_PATH.'lite.php'
配置后,生成的Lite文件的位置为 APP_PATH.'lite.php'。
Lite文件的编译文件内容是系统默认的,如果希望改变或者增加其他的编译文件的话,可以在外部定义编译列表文件,例如: 我们在应用配置目录下面增加lite.php定义如下:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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, ); |
所有在lite.php文件中定义的文件都会纳入Lite文件的编译缓存中。你还可以对生成的lite文件进行修改。
如果你修改了框架文件和应用函数和配置文件的话,需要删除Lite文件重新生成。
由于SAE等云平台不支持文件写入,因此不支持直接生成Lite文件。
替换入口
Lite文件可以用于替换框架入口文件或者应用入口文件。
替换框架入口文件
Lite文件生成后,就可以把原来的应用入口文件中的框架入口文件修改如下:
代码如下:
require './ThinkPHP/ThinkPHP.php';
改成:
代码如下:
require './Runtime/lite.php';
替换Lite文件后,应用编译缓存不再需要。
替换应用入口文件
如果你的入口文件没有其他代码和逻辑的话,还可以直接把lite.php文件作为应用的入口文件访问。 把lite.php 文件复制到应用入口文件的相同目录,并直接改名为index.php即可和原来一样正常访问(原来的应用入口文件可以备份以备用于重新生成Lite文件的时候使用)。
注意:如果你的环境或者目录位置发生变化,以及更改了核心框架和应用函数、配置等文件后,则需要重新生成Lite文件。
希望本文所述对大家的基于ThinkPHP框架的php程序设计有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



When deleting or decompressing a folder on your computer, sometimes a prompt dialog box "Error 0x80004005: Unspecified Error" will pop up. How should you solve this situation? There are actually many reasons why the error code 0x80004005 is prompted, but most of them are caused by viruses. We can re-register the dll to solve the problem. Below, the editor will explain to you the experience of handling the 0x80004005 error code. Some users are prompted with error code 0X80004005 when using their computers. The 0x80004005 error is mainly caused by the computer not correctly registering certain dynamic link library files, or by a firewall that does not allow HTTPS connections between the computer and the Internet. So how about

Quark Netdisk and Baidu Netdisk are currently the most commonly used Netdisk software for storing files. If you want to save the files in Quark Netdisk to Baidu Netdisk, how do you do it? In this issue, the editor has compiled the tutorial steps for transferring files from Quark Network Disk computer to Baidu Network Disk. Let’s take a look at how to operate it. How to save Quark network disk files to Baidu network disk? To transfer files from Quark Network Disk to Baidu Network Disk, you first need to download the required files from Quark Network Disk, then select the target folder in the Baidu Network Disk client and open it. Then, drag and drop the files downloaded from Quark Cloud Disk into the folder opened by the Baidu Cloud Disk client, or use the upload function to add the files to Baidu Cloud Disk. Make sure to check whether the file was successfully transferred in Baidu Cloud Disk after the upload is completed. That's it

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

A file path is a string used by the operating system to identify and locate a file or folder. In file paths, there are two common symbols separating paths, namely forward slash (/) and backslash (). These two symbols have different uses and meanings in different operating systems. The forward slash (/) is a commonly used path separator in Unix and Linux systems. On these systems, file paths start from the root directory (/) and are separated by forward slashes between each directory. For example, the path /home/user/Docume

Recently, many netizens have asked the editor, what is the file hiberfil.sys? Can hiberfil.sys take up a lot of C drive space and be deleted? The editor can tell you that the hiberfil.sys file can be deleted. Let’s take a look at the details below. hiberfil.sys is a hidden file in the Windows system and also a system hibernation file. It is usually stored in the root directory of the C drive, and its size is equivalent to the size of the system's installed memory. This file is used when the computer is hibernated and contains the memory data of the current system so that it can be quickly restored to the previous state during recovery. Since its size is equal to the memory capacity, it may take up a larger amount of hard drive space. hiber

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.
