Home >PHP Framework >ThinkPHP >Learning: ThinkPHP deployment directory

Learning: ThinkPHP deployment directory

藏色散人
藏色散人forward
2020-11-20 14:32:013433browse

The following is an introduction to the ThinkPHP deployment directory from the thinkphp framework tutorial column. I hope it will be helpful to friends in need!

1. Problem: I was very confused about the directory structure when writing the project according to the deployment directory instructions in document 2.2.3
2. Solution: (Officially gives two deployment solutions)
1. Official recommendation Solution
Official recommended solution: (Table of contents as shown below)

#Operation Steps:

1.1 Download the ThinkPHP software package, create a new TESTAPP directory, and put the ThinkPHP folder into the TESTAPP folder.

1.2 If necessary Create the front-end directory Home and the back-end directory Admin, and create a new entry file index.php in the TESTAPP folder (used to create the Home directory). The code is as follows:

<?php

//1.确定前台文件夹名称 Home

define(&#39;APP_NAME&#39;,&#39;Home&#39;);

//2.确定应用路径

define(&#39;APP_PATH&#39;,&#39;./Home/&#39;);

//3.开启调试模式

define(&#39;APP_DEBUG&#39;,true);

//4.应用核心文件

require &#39;./ThinkPHP/ThinkPHP.php&#39;;

1.3 Create a new entry file admin.php in the TESTAPP folder (used to create the Admin directory). The code is as follows:

<?php

//1.确定后台文件名称 Admin

define(&#39;APP_NAME&#39;,&#39;Admin&#39;);

//2.确定应用路径

define(&#39;APP_PATH&#39;,&#39;./Admin/&#39;);

//3.开启调试模式,防止缓存造成调试问题

define(&#39;APP_DEBUG&#39;,true);

//4.应用核心文件

require &#39;./ThinkPHP/ThinkPHP.php&#39;;

1.4 After the two files are written, enter them in the browser. http://localhost/bbs/index.php automatically generates the Home folder, enter http://localhost/bbs/admin.php

When you see the Welcome to thinkPHP prompt, the directory structure is as shown in the figure:

Deployment Finish.

1.5 Start writing code

If you need a User controller, create a new UserAction.class in the Admin folder. php, write the following code:

##

<?php

class UserAction extends Action {
    public function index(){
    	        
        $this->user=M(&#39;user&#39;)->select();
  
        
        $this->display();    
    }
}

Create a new folder Home in tpl, create a new File index.html, write the following code:

##

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <!-- 引入 jquery 和 layer 插件 -->
     <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
     <script src="http://apps.bdimg.com/libs/layer/2.1/layer.js"></script>
</head>
<body>
        <a href="__URL__/add">添加</a>
    <table>
    <volist id="vo" name="user">
        
            <tr>
                <td>{$vo.username}</td>
                <td><a href="{:U(&#39;Index/edit&#39;,array(&#39;id&#39;=>$vo[&#39;id&#39;]))}">修 改</a></td>
            </tr>
        
    </volist>
    </table> 

</body>
</html>
Configure database information in config.php in Conf in the Admin folder

Enter the URL http://localhost/TESTAPP/admin.php/User/index, you can see the results

2. Group module solution (will be added after testing)

The above is the detailed content of Learning: ThinkPHP deployment directory. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete