How to set up a custom directory structure in ThinkPHP

不言
Release: 2023-03-30 07:18:01
Original
2148 people have browsed it

Nowadays, many friends like to use ThinkPHP, but some friends don’t like the many directories it generates. Here I will share with you how to put all the directories into the include directory, which is much cleaner.

The effect is as shown in the figure Shown:

Entry file

<?php
// 应用入口文件
 
// 检测PHP环境
if(version_compare(PHP_VERSION,&#39;5.3.0&#39;,&#39;<&#39;)) die(&#39;require PHP > 5.3.0 !&#39;);
 
// 网站文件入口位置
define(&#39;ABSPATH&#39;, dirname(__FILE__) . &#39;/&#39;);
 
// 定义应用目录
define(&#39;APP_NAME&#39;, &#39;WEBSITE&#39;);
define(&#39;APP_PATH&#39;,&#39;./include/&#39;);
define(&#39;CONF_PATH&#39;, ABSPATH . &#39;/config/&#39;);
define(&#39;RUNTIME_PATH&#39;, ABSPATH . &#39;/cache/&#39;);
define(&#39;TMPL_PATH&#39;, ABSPATH . &#39;/templates/&#39;);
define(&#39;UPLOAD_PATH&#39;, ABSPATH . &#39;/uploads/&#39;);
define(&#39;THINK_PATH&#39;, APP_PATH . &#39;/ThinkPHP/&#39;);
 
// 开启调试模式
define(&#39;APP_DEBUG&#39;,True);
 
// 引入ThinkPHP入口文件
require THINK_PATH . &#39;ThinkPHP.php&#39;;
Copy after login

Configuration file

<?php
return array (
 &#39;DEFAULT_MODULE&#39; => &#39;APP&#39;,
 &#39;URL_MODEL&#39; => &#39;2&#39;,
 &#39;TMPL_PARSE_STRING&#39;=> array(
 &#39;__PUBLIC__&#39; => __ROOT__.&#39;/static&#39;,
 &#39;__UPLOAD__&#39; => __ROOT__.&#39;/uploads&#39;
 ),
 &#39;TMPL_FILE_DEPR&#39; => &#39;_&#39;,
);
Copy after login

Related recommendations:

Thinkphp passed How does an entry file distinguish the mobile terminal and PC terminal

How does the thinkphp project customize the WeChat sharing description content

The above is the detailed content of How to set up a custom directory structure in ThinkPHP. For more information, please follow other related articles on the PHP Chinese website!

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
Popular Tutorials
More>
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!