Home> PHP Framework> ThinkPHP> body text

Where to put thinkphp entry file

藏色散人
Release: 2019-08-23 13:21:54
Original
5129 people have browsed it

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 atpublic/index.php, the content is as follows:

// 定义应用目录 define('APP_PATH', __DIR__ . '/../application/'); // 加载框架引导文件 require __DIR__ . '/../thinkphp/start.php';
Copy after login

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

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();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!