|
tmphp_start
快速学习TMPHP安装TMPHP
# # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "/path-to/tmphp-framework/demo/view" 如果文件夹有权限问题,建议设置为655权限,Apache访问设置为 Allow from all:
使用TMPHP
我们的应用目录要包含一些基础的目录设定,这个是框架要求的,假设我们的应用是 demo,放在 /path/to/demo 路径,那么我们在 demo 目录中最少要包括如下目录:
配置在 demo/config/Config.ini,如果你追求更快性能,可以使用数组方式,建立一个 demo/config/Config.php 文件,里面写上配置内容:<?php return array ( //公共配置 'Common' => array ( 'UrlReWrite' => '', //是否开启urlrewrite 'CharSet' => 'UTF-8', //文档编码 'TimeZone' => 'Asia/Chongqing', //时区设置 'UrlHtml' => '1', //是否开启伪静态 'AutoFilter' => '1', //是否进行自动对POST.GET.COOKIE进行过滤 'HostEnv' => 'dev', //当前框架运行环境: 开发环境(dev)/测试环境(test)/运营生产环境(prod) ), 'Framework' => array ( 'ControllerName' => 'c', //控制器变量名 'ActionName' => 'a', //Action 变量名 'DefaultController' => 'index', //缺省的控制器名 'DefaultAction' => 'index', //缺省的Action名 ), //数据库配置 'DataBase' => array ( 'driver' => 'DB_Mysql', //数据库访问驱动 'host' => 'localhost', //数据库主机地址 'user' => 'root', //数据库连接账户名 'pwd' => '', //数据库连接密码 'db' => 'test', //数据库名 'charset' => 'utf8', //数据库字符集 ), ); 如果你喜欢ini的配置方式,也可以建立 demo/config/Config.ini 文件,大致内容如下:;; ;; 公共配置 ;; [Common] UrlReWrite = false ;; 是否开启urlrewrite CharSet = UTF-8 ;; 文档编码 TimeZone = Asia/Chongqing ;; 时区设置 UrlHtml = true ;; 是否开启伪静态 AutoFilter = true ;; 是否进行自动对POST.GET.COOKIE进行过滤 HostEnv = dev ;; 当前框架运行环境: 开发环境(dev)/测试环境(test)/运营生产环境(prod) [Framework] ControllerName = c ;; 控制器变量名 ActionName = a ;; Action 变量名 DefaultController = index ;; 缺省的控制器名 DefaultAction = index ;; 缺省的Action名 ;; ;; 数据库配置 ;; [DataBase] ;;Connection = false ;; 是否连接数据库 driver = DB_Mysql ;; 数据库访问驱动 host = localhost ;; 数据库主机地址 user = root ;; 数据库连接账户名 pwd = ;; 数据库连接密码 db = test ;; 数据库名 charset = utf8 ;; 数据库字符集 入口文件就是我们Web服务器会首先访问的文件,一般是 index.php,我们这里的示例是 demo/view/inddex.php 文件,这个文件主要设定框架主目录、应用主目录、进行dispatch操作等,我们看我们demo 的 index.php 文件:
基本现在我们的应用就可以工作了,我们访问我们的框架,应该会在网页里看到如下错误提示:TMPHP Exception: controller file /path/to/tmphp-framework/demo/controller/indexController.class.php not exist or not readable下面我们学习如何建立控制器
我们缺省的控制器是 index ,那么我们建立一个控制器类在 demo/controller/indexController.class.php:
这时候访问我们的应用,网页里会提示: TMPHP Exception: controller class method indexController->indexAction() not exist 说我们没有缺省的Action方法,我们在 indexController 类里建立一个 indexAction() 方法:
访问应用,应该在网页里看到显示:我是一个缺省Action 建立基本应用成功!
|
► Sign in to add a comment
看看是什么东西