ZF学习使用之hello world

ZF 1.11.2

PHP 5.3

创建虚拟站点httpd_vhost.conf

<VirtualHost 192.168.1.106:80>
<Directory "E:/www/zf">
DirectoryIndex index.php
AllowOverride all
Options -Indexes FollowSymLinks
</Directory>
ServerAdmin coderzl@hotmail.com   
DocumentRoot E:/www/zf/public
ServerName zf.zaric.com
ErrorLog "E:/www/logs/zf.localhost-error.log"
CustomLog "E:/www/logs/zf.localhost-access.log" common
</VirtualHost>

/public/.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$  /index.php/$1 [PT,L]

工程目录结构:

image

创建index.php

error_reporting(E_ALL | E_STRICT);            //设定Error Report的等级
date_default_timezone_set('Asia/Taipei');    //设定时区为台北

//Include path
define ('P_S', PATH_SEPARATOR);
set_include_path('.' .P_S .'../library' .P_S .'../application/models/' .P_S .get_include_path());
require('Zend/Loader/Autoloader.php');
Zend_Loader ::registerAutoload();

image 

最后一句提示:Zend_Loader::Zend_Loader::registerAutoload is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader,过期用Zend_Loader_Autoloader替代。

下来

Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);//能够载入无名子空间的类,比如models目录下的类。
$controller = Zend_Controller_Front::getInstance();
$controller->setParam('useDefaultControllerAlways', true);
$controller->setControllerDirectory('../application/controllers/');
$controller->setBaseUrl('../application/controllers/');
$controller->dispatch();

建立:/application/controllers/IndexController.php

class IndexController extends Zend_Controller_Action
{
    function indexAction(){}

    function doAction(){}
}

同时建立:/application/views/script/index/index.phtml

否则会报出异常:Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)

最后运行:http://zf.zaric.com/index/index

image

http://zf.zaric.com/index/do

image

done!~

转载于:https://www.cnblogs.com/zaric/archive/2011/02/17/1957268.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值