Entry file
Thinkphp uses a single entry mode for project deployment and access, and regardless of what functionality is completed, an application has a unified (but not necessarily unique) portal.
It should be said that all applications start with a portal file, and the entry files for different applications are similar.
Portal file Definition
The entry file is mainly completed:
- Define frame path, project path (optional)
- Define system-dependent constants (optional)
- Load frame entry file (required)
5.0 The default application portal file is located public/index.php with the following content:
// 定义应用目录define(‘APP_PATH‘, __DIR__ . ‘/../application/‘);// 加载框架引导文件require __DIR__ . ‘/../thinkphp/start.php‘;
入口文件位置的设计是为了让应用部署更安全,public目录为web可访问目录,其他的文件都可以放到非WEB访问目录下面。
Some system variables can also be defined in the portal file for related binding operations (typically used for multiple portals), which are later involved and are not mentioned.
APP_PATHdefining an absolute path increases the efficiency of the system's loading.
In some cases, you may need to load the framework's underlying boot file base.php , and the difference between the boot file and the one that start.php is not actively executing the app, but the need to do the application itself, here is an example:
// 定义应用目录define(‘APP_PATH‘, __DIR__ . ‘/../application/‘);// 加载框架基础引导文件require __DIR__ . ‘/../thinkphp/base.php‘;// 添加额外的代码// ...// 执行应用\think\App::run()->send();
thinkphp5.0 Portal File