Home >PHP Framework >ThinkPHP >Learning: ThinkPHP deployment directory
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('APP_NAME','Home'); //2.确定应用路径 define('APP_PATH','./Home/'); //3.开启调试模式 define('APP_DEBUG',true); //4.应用核心文件 require './ThinkPHP/ThinkPHP.php';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('APP_NAME','Admin'); //2.确定应用路径 define('APP_PATH','./Admin/'); //3.开启调试模式,防止缓存造成调试问题 define('APP_DEBUG',true); //4.应用核心文件 require './ThinkPHP/ThinkPHP.php';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('user')->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('Index/edit',array('id'=>$vo['id']))}">修 改</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!