04 2010

Window7 xampp下zend framework 1.10.7 quickstart、配置与调试

Category: Zend Frameworklixiphp @ 2010-08-04 21:37:03

you can » Download the latest version of Zend Framework and extract the contents; make a note of where you have done so.

Create Your Project

  • zf Command Line Tool的安装

第一步:首先环境变量设置,在系统变量一栏找到Path变量,编辑,添加

D:\xampp\php;D:\xampp\htdocs\ZendFramework-1.10.7\bin

我这里安装的xampp,自己的安装目录不同,请自行更改

第二步:检测安装,开始-》运行(或者直接win+R键) –》 输入cmd -》输入一下命令

C:\Users\bruce>php -version
PHP 5.2.6 (cli) (built: May  2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
    with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
    with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies

如果出现你的php版本,说明你的php命令环境安装成功!

C:\Users\bruce>zf ? version
Zend Framework Command Line Console Tool v1.10.7
Actions supported by provider "Version"
  Version
    zf show version mode[=mini] name-included[=1]
    Note: There are specialties, use zf show version.? to get specific help on them.

如果出现你的Zend Framework信息,说明你的Zend Framework Command Line Console Tool 环境安装成功!

  • Command 完成工程的建立

cd D:\xampp\htdocs\ZendFramework-1.10.7

进入安装project的虚拟目录,接着:

D:\xampp\htdocs\ZendFramework-1.10.7>zf create project quickstart
Creating project at D:/xampp/htdocs/ZendFramework-1.10.7/quickstart
Note: This command created a web project, for more information setting up your VHOST, please see docs/README

提示project已经建立到quickstart目录中,Command提示VHOST安装的信息,我们的xampp已经完成了。

Running this command will create your basic site structure, including your initial controllers and views. The tree looks like the following:

D:\XAMPP\HTDOCS\ZENDFRAMEWORK-1.10.7\QUICKSTART
├─application
│  ├─configs
│  ├─controllers
│  ├─models
│  └─views
│      ├─helpers
│      └─scripts
│          ├─error
│          └─index
├─docs
├─library
├─public
└─tests
    ├─application
    └─library

copying ZendFramework-1.10.7\library 到 your quickstart\library/ directory.

访问http://127.0.0.1/ZendFramework-1.10.7/quickstart/public/index.php

你会看到以下图片:

image-Welcome to the Zend Framework!

阅读更多>>

标签: , , , , , , ,


十二 17 2009

简单设置Zend Framework 404基本路径Zend_View::render

Category: Zend Frameworklixiphp @ 2009-12-17 22:23:19

今天在使用Zend Framework时设置404页面错误时,由于ZF 1.9.6的 视图目录为 application/view/scripts/index/404.php,而这个render函数不能自动识别当前controller的视图目录,所以需要把404模板移到controller对应的视图目录下。所以用到以下笨方法:

$thispath = reset($this->view->getScriptPaths());
$this->view->setScriptPath($thispath . "index/");
echo $this->view->render('404.php');//显示模版

注:controller为index

一、函数说明:

/**
* Retrieve the current script paths
* 获取当前脚本路径
*/
public function getScriptPaths();

/**
* Set the path to view scripts/templates
* 设置视图脚本的路径
*/
public function setScriptPath($path);

/**
* Render the template named $name
* 输出参数$name指定的某个模板
*/
public function render($name);

二、环境说明:

Zend Framework library = 1.9.6

标签: , , , ,