/wwwRoot/mydemo/ # 項目根目錄
index.php # 入口文件
thinkphp/ # 框架核心目錄
index.php<?php
define('THINK_PATH', 'thinkphp');
define('APP_NAME', 'Hello');
define('APP_PATH', '.');
require(THINK_PATH . "/ThinkPHP.php");
$App = new App();
$App->run();
?>
瀏覽器訪問 https://localhost/mydemo/,框架自動創建:
lib/
action/
IndexAction.class.php
model/
tpl/
default/
index.html
lib/action/IndexAction.class.php<?php
class IndexAction extends Action {
public function index() {
// 默認動作
}
}
?>
tpl/default/index.html{$welcome_info}
<?php
class IndexAction extends Action {
public function index() {
header("Content-Type:text/html; charset=utf-8");
$this->assign("welcome_info", "Hello World!");
$this->display();
}
}
?>
入口文件/模塊名/操作名
# 例:/index.php/Index/index
# 默認:Index 模塊 + index 操作
再次訪問,輸出 Hello World!。ThinkPHP 以「約定優於配置」讓 MVC 開發極致簡單。