Home >PHP Framework >ThinkPHP >Where to put thinkphp entry file
#Where to put the thinkphp entry file?
ThinkPHP adopts a single entry mode for project deployment and access. No matter what function is completed, an application has a unified (but not necessarily the only) entry.
It should be said that all applications start from the entry file, and the entry files of different applications are similar.
Entry file definition
The entry file is mainly completed:
Define the framework path and project path (optional)
Define system-related constants (optional)
Load the framework entry file (required)
5.0 The default application entry file is located at public/index.php
, the content is as follows:
// 定义应用目录 define('APP_PATH', __DIR__ . '/../application/'); // 加载框架引导文件 require __DIR__ . '/../thinkphp/start.php';
The entry file location is designed to make application deployment more secure. The public directory is a web-accessible directory, and other files can be placed in non-WEB-accessible directories.
To modify the location of the entry file, please see the chapter 96c0d429f07d6faa1c7043709cf4eff5
The entry file can also define some system variables for related binding operations (usually used for multiple entrance), this will be covered later and will not be mentioned for now.
Defining an absolute path for APP_PATH will improve the loading efficiency of the system.
In some cases, you may need to load the basic boot file base.php of the framework. The difference between this boot file and start.php is that it will not actively execute the application, but needs to execute the application yourself. The following is An example:
// 定义应用目录 define('APP_PATH', __DIR__ . '/../application/'); // 加载框架基础引导文件 require __DIR__ . '/../thinkphp/base.php'; // 添加额外的代码 // ... // 执行应用 \think\App::run()->send();
This article comes from the ThinkPHP framework technical article column: //m.sbmmt.com/phpkj/thinkphp/
The above is the detailed content of Where to put thinkphp entry file. For more information, please follow other related articles on the PHP Chinese website!