Zend Framework学习笔记1

(以下的环境是windows下,ZF1.9.5版本)

1 下周zf的源码库。并配置bin文件夹为系统变量。

 

2 查看ZF的版本,cmd下,运行:

zf show version 

 

3 进入cmd,在需要建立zf project的目录内,运行:

zf.bat create project quickstart


4 需要把zend的 library 文件夹下的 zend 文件夹copy 到 相应项目的 library 下。


5 环境的定义:是在.htaccess中定义的,SetEnv APPLICATION_ENV development 。如果没有定义的话,则默认是production环境。


6 layout的设置:

  A 配置文件添加

; application/configs/application.ini

; Add to [production] section: 

resources.view[] =  

  B 引导程序(Bootstrap)中配置默认的layout的通用参数。

 

ContractedBlock.gif ExpandedBlockStart.gif Bootstrap.php
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><?php
// application/Bootstrap.php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    
protected function _initDoctype()
    {
        
$this->bootstrap('view');
        
$view = $this->getResource('view');
        
$view->doctype('XHTML1_STRICT');
    }
}

 

  C 建立layout文件。 

 

ContractedBlock.gif ExpandedBlockStart.gif layout.phtml
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--><?php 
// application/layouts/scripts/layout.phtml

echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>  
  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  
<title>Zend Framework Quickstart Application</title>
  
<?php echo $this->headLink()->appendStylesheet('/css/global.css'?>
</head> 
<body>
<div id="header" style="background-color: #EEEEEE; height: 30px;">
    
<div id="header-logo" style="float: left">
        
<b>ZF Quickstart Application</b>
    
</div>
    
<div id="header-navigation" style="float: right">
        
<a href="<?php echo $this->url(
            array('controller'=>'guestbook'), 
            'default', 
            true) ?>
">Guestbook</a>
    
</div>
</div>

<?php echo $this->layout()->content ?>

</body>
</html>

 

7  创建控制器:

zf create controller posts

8  创建view:

zf create action view posts

9  创建action:

zf create action edit posts

10  数据库配置

; application/configs/application.ini

resources.db.adapter       = "PDO_MYSQL"
resources.db.params.host   = localhost
resources.db.params.port   = 3306
resources.db.params.username = root
resources.db.params.password =
resources.db.params.dbname   = zf_demo
resources.db.charset         = utf8

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值