PHP框架queryphp教程:入门一 Hello World
配置好php环境不会配置可以看下附录php安装 下载queryphp后,把解压出来
http://code.google.com/p/queryphp/downloads/list
放到一个目录里面
比如放到d:\work\queryphp目录
下面是目录结构
config 配置文件目录 precore.ini.php aftercore.ini.php
model 本项目模型文件
router 本项目路由文件
view 视图文件可以按路由目录存放
class 本项目使用的普通类文件
lib 存放类库文件或插件
等目录
域名配置
C:\WINDOWS\system32\drivers\etc\hosts文件添加一行
内容如下
127.0.0.1 localhost
192.168.0.10 www.tjwzjs.cn
在apapche2配置 在下面文件中多加上www.tjwzjs.cn配置
Apache2.2\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
<Directory "D:/work/tjwzjs/sf/web">
Order allow,deny
Allow from all
AllowOverride FileInfo
</Directory>
DocumentRoot "D:/work/tjwzjs/sf/web"
ServerName "www.tjwzjs.cn"
</VirtualHost>
当然要在Apache2.2\conf\httpd.conf
里面设置打开httpd-vhosts.conf文件 打开了虚拟主机文件就不用了
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
编写代码
配置好后测试了在project/router目录添加 defaultRouter.class.php
<?php
class defaultRouter extends controller{
function index()
{
echo "Hello world!";
return false;
}
}
?>
然后使用http://www.tjwzjs.cn/project/index.php 看看是否显示了
下面是访问后样子 也可以使用 http://www.tjwzjs.cn/project/index.php/default/index default 是router名 index是方法
不支持pathinfo 可以使用http://www.tjwzjs.cn/project/index.php?router=default&action=index
我们现在入口文件为index.php 也可以换成别的文件。function index() 是方法 可以添加多个方法 比如:
function login() /index.php/default/login
function show() //可能是/index.php/default/show/id/565 带参数 这样可以使用$_GET['id']取得
如果添加多个router文件同样是curdRouter.class.php样子放在router目录
调用方式是 index.php/curd/xxxx 这样调用curdRouter.class.php里面的方法
那个内存:1.5M提示信息是 在index.php文件里面,不要可以去除
调试和配置
下面新手可以不用看
也可以自己装debug方式查看
比如使用: WinCacheGrind 查看执行方式
debug配置方式 下面是php.ini配置 经常要自己手动清除下c:\tmp目录
;zend_extension_manager.optimizer_ts="C:\Program Files\Zend\ZendOptimizer-3.2.2\lib\Optimizer-3.2.2"
;zend_extension_ts="C:\Program Files\Zend\ZendOptimizer-3.2.2\lib\ZendExtensionManager.dll"
;zend_extension_ts="c:\php\ext\php_xdebug-2.0.5-5.2.dll"
zend_extension_ts="C:/php/ext/php_xdebug-2.0.5-5.2.dll"
xdebug.remote_enable=on
xdebug.remote_autostart=on
xdebug.remote_log="C:/tmp/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.remote_host=localhost
xdebug.idekey=default
xdebug.profiler_enable=on
xdebug.profiler_enable_trigger=on
xdebug.profiler_output_dir="c:/tmp"
xdebug.profiler_output_name="cachegrind.out.%t"
页:
[1]