Zend Framework開發(fā)入門經(jīng)典教程
本文講述了Zend Framework開發(fā)入門相關(guān)知識點(diǎn)。分享給大家供大家參考,具體如下:
Zend Framework發(fā)布了!雖然仍處于開發(fā)初期,這個教程仍突出講解目前幾個最好的功能,并指導(dǎo)你完成一個簡單程序的構(gòu)建。
Zend最早在社區(qū)里發(fā)布了ZF。基于同樣的想法,這個教程寫來用于展示ZF現(xiàn)有的功能。由于這個教程是在線發(fā)布,我將在ZF變化時對其進(jìn)行更新,以便盡可能有效。
要求
Zend Framework要求PHP5。為了更好利用本教程的代碼,你還需要Apache網(wǎng)頁服務(wù)器。因?yàn)槭痉冻绦颍ㄒ粋€新聞管理系統(tǒng))用到了mod_rewrite。
這個教程的代碼可以自由下載,所以你可以自己試一下。你可以從Brain Buld的網(wǎng)站下載到代碼:http://brainbulb.com/zend-framework-tutorial.tar.gz。
下載ZF
當(dāng)你開始這篇教程時,你需要下載ZF的最新版本。你可以用瀏覽器手工從http://framework.zend.com/download選擇tar.gz或zip文件進(jìn)行下載,或者使用下列命令:
$ wget http://framework.zend.com/download/tgz $ tar -xvzf ZendFramework-0.1.2.tar.gz
提示:Zend計(jì)劃提供自有PEAR通道簡化下載。
一旦你下載了預(yù)覽版,把library目錄放到方便的地方。在這個教程,我把library重命名為lib以便有個簡潔的目錄結(jié)構(gòu):
app/
views/
controllers/
www/
.htaccess
index.php
lib/
www目錄是文檔根目錄,controllers和views目錄是以后會用到的空目錄,而lib目錄來自你下載的預(yù)覽版。
開始
我要介紹的第一個組件是Zend_Controller。從很多方面看,它為你開發(fā)的程序提供了基礎(chǔ),同時也部分決定了Zend Framework不只是個組件的集合。但是,你在用之前需要將所有的得到的請求都放到一個簡單的PHP腳本。本教程用的是mod_rewrite。
用mod_rewrite自身是一種藝術(shù),但幸運(yùn)的是,這個特殊的任務(wù)特別簡單。如果你對mod_rewrite或Apache的一般配置不熟悉,在文檔根目錄下創(chuàng)建一個.htaccess文件,并添加以下內(nèi)容:
RewriteEngine on RewriteRule !/.(js|ico|gif|jpg|png|css)$ index.php
提示: Zend_Controller的一個TODO項(xiàng)目就是取消對mod_rewrite的依賴。為了提供一個預(yù)覽版的范例,本教程用了mod_rewrite。
如果你直接把這些內(nèi)容添加到httpd.conf,你必須重啟網(wǎng)頁服務(wù)器。但如果你用.htaccess文件,則什么都不必做。你可以放一些具體的文本到index.php并訪問任意路徑如/foo/bar做一下快速測試。如你的域名為example.org,則訪問http://example.org/foo/bar。
你還要設(shè)置ZF庫的路徑到include_path。你可以在php.ini設(shè)置,也可以直接在你的.htaccess文件放下列內(nèi)容:
php_value include_path "/path/to/lib"
Zend
Zend類包含了一些經(jīng)常使用的靜態(tài)方法的集合。下面是唯一一個你要手工添加的類:
<?php include 'Zend.php'; ?>
一旦你包含了Zend.php,你就已經(jīng)包含了Zend類的所有的類方法。用loadClass()就可以簡單地加載其它類。例如,加載Zend_Controller_Front類:
<?php
include 'Zend.php';
Zend::loadClass('Zend_Controller_Front');
?>
include_path能理解loadclass()及ZF的組織和目錄結(jié)構(gòu)。我用它加載所有其它類。
Zend_Controller
使用這個controller非常直觀。事實(shí)上,我寫本教程時并沒有用到它豐富的文檔。
提示:文檔目前已經(jīng)可以在http://framework.zend.com/manual/zend.controller.html看到。
我一開始是用一個叫Zend_Controller_Front的front controller。為了理解它是怎么工作的,請把下列代碼放在你的index.php文件:
<?php
include 'Zend.php';
Zend::loadClass('Zend_Controller_Front');
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory('/path/to/controllers');
$controller->dispatch();
?>
如果你更喜歡對象鏈結(jié),可以用以下代碼代替:
<?php
include 'Zend.php';
Zend::loadClass('Zend_Controller_Front');
$controller = Zend_Controller_Front::getInstance()
->setControllerDirectory('/path/to/controllers')
->dispatch();
?>
現(xiàn)在如果你訪問/foo/bar,會有錯誤發(fā)生。沒錯!它讓你知道發(fā)生了什么事。主要的問題是找不到IndexController.php文件。
在你創(chuàng)建這個文件之前,應(yīng)先理解一下ZF想讓你怎樣組織這些事情。ZF把訪問請求給拆分開來。假如訪問的是/foo/bar,則foo是controller,而bar是action。它們的默認(rèn)值都是index.
如果foo是controller,ZF就會去查找controllers目錄下的FooController.php文件。因?yàn)檫@個文件不存在,ZF就退回到IndexController.php。結(jié)果都沒有找到,就報錯了。
接下來,在controllers目錄創(chuàng)建IndexController.php文件(可以用setControllerDirectory()設(shè)置):
<?php
Zend::loadClass('Zend_Controller_Action');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'IndexController::indexAction()';
}
}
?>
就如剛才說明的,IndexController類處理來自index controller或controller不存在的請求。indexAction()方法處理action為index的訪問。要記住的是index是controller和action的默認(rèn)值。如果你訪問/,/index或/index/index,indexAction()方法就會被執(zhí)行。 (最后面的斜杠并不會改變這個行為。) 而訪問其他任何資源只會導(dǎo)致出錯。
在繼續(xù)做之前,還要在IndexController加上另外一個有用的類方法。不管什么時候訪問一個不存在的控制器,都要調(diào)用noRouteAction()類方法。例如,在FooController.php不存在的條件下,訪問/foo/bar就會執(zhí)行noRouteAction()。但是訪問/index/foo仍會出錯,因?yàn)閒oo是action,而不是controller.
將noRouteAction()添加到IndexController.php:
<?php
Zend::loadClass('Zend_Controller_Action');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'IndexController::indexAction()';
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
例子中使用$this->_redirect('/')來描述執(zhí)行noRouteAction()時,可能發(fā)生的行為。這會將對不存在controllers的訪問重定向到根文檔(首頁)。
現(xiàn)在創(chuàng)建FooController.php:
<?php
Zend::loadClass('Zend_Controller_Action');
class FooController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'FooController::indexAction()';
}
public function barAction()
{
echo 'FooController::barAction()';
}
}
?>
如果你再次訪問/foo/bar,你會發(fā)現(xiàn)執(zhí)行了barAction(),因?yàn)閎ar是action?,F(xiàn)在你不只支持了友好的URL,還可以只用幾行代碼就做得這么有條理??岚?!
你也可以創(chuàng)建一個__call()類方法來處理像/foo/baz這樣未定義的action。
<?php
Zend::loadClass('Zend_Controller_Action');
class FooController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'FooController::indexAction()';
}
public function barAction()
{
echo 'FooController::barAction()';
}
public function __call($action, $arguments)
{
echo 'FooController:__call()';
}
}
?>
現(xiàn)在你只要幾行代碼就可以很好地處理用戶的訪問了,準(zhǔn)備好繼續(xù)。
Zend_View
Zend_View是一個用來幫助你組織好你的view邏輯的類。這對于模板-系統(tǒng)是不可知的,為了簡單起見,本教程不使用模板。如果你喜歡的話,不妨用一下。
記住,現(xiàn)在所有的訪問都是由front controller進(jìn)行處理。因此應(yīng)用框架已經(jīng)存在了,另外也必須遵守它。為了展示Zend_View的一個基本應(yīng)用,將IndexController.php修改如下:
<?php
Zend::loadClass('Zend_Controller_Action');
Zend::loadClass('Zend_View');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$view = new Zend_View();
$view->setScriptPath('/path/to/views');
echo $view->render('example.php');
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
在views目錄創(chuàng)建example.php文件:
<html> <head> <title>This Is an Example</title> </head> <body> <p>This is an example.</p> </body> </html>
現(xiàn)在,如果你訪問自己網(wǎng)站的根資源,你會看到example.php的內(nèi)容。這仍沒什么用,但你要清楚你要在以一種結(jié)構(gòu)和組織非常清楚的方式在開發(fā)網(wǎng)絡(luò)應(yīng)用。
為了讓Zend_View的應(yīng)用更清楚一點(diǎn),,修改你的模板(example.php)包含以下內(nèi)容:
<html> <head> <title><?php echo $this->escape($this->title); ?></title> </head> <body> <?php echo $this->escape($this->body); ?> </body> </html>
現(xiàn)在已經(jīng)添加了兩個功能。$this->escape()類方法用于所有的輸出。即使你自己創(chuàng)建輸出,就像這個例子一樣。避開所有輸出也是一個很好的習(xí)慣,它可以在默認(rèn)情況下幫助你防止跨站腳本攻擊(XSS)。
$this->title和$this->body屬性用來展示動態(tài)數(shù)據(jù)。這些也可以在controller中定義,所以我們修改IndexController.php以指定它們:
<?php
Zend::loadClass('Zend_Controller_Action');
Zend::loadClass('Zend_View');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$view = new Zend_View();
$view->setScriptPath('/path/to/views');
$view->title = 'Dynamic Title';
$view->body = 'This is a dynamic body.';
echo $view->render('example.php');
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
現(xiàn)在你再次訪問根目錄,應(yīng)該就可以看到模板所使用的這些值了。因?yàn)槟阍谀0逯惺褂玫?this就是在Zend_View范圍內(nèi)所執(zhí)行的實(shí)例。
要記住example.php只是一個普通的PHP腳本,所以你完全可以做你想做的。只是應(yīng)努力只在要求顯示數(shù)據(jù)時才使用模板。你的controller (controller分發(fā)的模塊)應(yīng)處理你全部的業(yè)務(wù)邏輯。
在繼續(xù)之前,我想做最后一個關(guān)于Zend_View的提示。在controller的每個類方法內(nèi)初始化$view對象需要額外輸入一些內(nèi)容,而我們的主要目標(biāo)是讓快速開發(fā)網(wǎng)絡(luò)應(yīng)用更簡單。如果所有模板都放在一個目錄下,是否要在每個例子中都調(diào)用setScriptPath()也存在爭議。
幸運(yùn)的是,Zend類包含了一個寄存器來幫助減少工作量。你可以用register()方法把你的$view對象存儲在寄存器:
<?php
Zend::register('view', $view);
?>
用registry()方法進(jìn)行檢索:
<?php
$view = Zend::registry('view');
?>
基于這點(diǎn),本教程使用寄存器。
Zend_InputFilter
本教程討論的最后一個組件是Zend_InputFilter。這個類提供了一種簡單而有效的輸入過濾方法。你可以通過提供一組待過濾數(shù)據(jù)來進(jìn)行初始化。
<?php $filterPost = new Zend_InputFilter($_POST); ?>
這會將($_POST)設(shè)置為NULL,所以就不能直接進(jìn)入了。Zend_InputFilter提供了一個簡單、集中的根據(jù)特定規(guī)則過濾數(shù)據(jù)的類方法集。例如,你可以用getAlpha()來獲取$_POST['name']中的字母:
<?php
/* $_POST['name'] = 'John123Doe'; */
$filterPost = new Zend_InputFilter($_POST);
/* $_POST = NULL; */
$alphaName = $filterPost->getAlpha('name');
/* $alphaName = 'JohnDoe'; */
?>
每一個類方法的參數(shù)都是對應(yīng)要過濾的元素的關(guān)鍵詞。對象(例子中的$filterPost)可以保護(hù)數(shù)據(jù)不被篡改,并能更好地控制對數(shù)據(jù)的操作及一致性。因此,當(dāng)你操縱輸入數(shù)據(jù),應(yīng)始終使用Zend_InputFilter。
提示:Zend_Filter提供與Zend_InputFilter方法一樣的靜態(tài)方法。
構(gòu)建新聞管理系統(tǒng)
雖然預(yù)覽版提供了許多組件(甚至許多已經(jīng)被開發(fā)),我們已經(jīng)討論了構(gòu)建一個簡單程序所需要的全部組件。在這里,你會對ZF的基本結(jié)構(gòu)和設(shè)計(jì)有更清楚的理解。
每個人開發(fā)的程序都會有所不同,而Zend Framework試圖包容這些差異。同樣,這個教程是根據(jù)我的喜好寫的,請根據(jù)自己的偏好自行調(diào)整。
當(dāng)我開發(fā)程序時,我會先做界面。這并不意味著我把時間都花在標(biāo)簽、樣式表和圖片上,而是我從一個用戶的角度去考慮問題。因此我把程序看成是頁面的集合,每一頁都是一個獨(dú)立的網(wǎng)址。這個新聞系統(tǒng)就是由以下網(wǎng)址組成的:
/
/add/news
/add/comment
/admin
/admin/approve
/view/{id}
你可以直接把這些網(wǎng)址和controller聯(lián)系起來。IndexController列出新聞,AddController添加新聞和評論,AdminController處理一些如批準(zhǔn)新聞之類的管理,ViewController特定新聞和對應(yīng)評論的顯示。
如果你的FooController.php還在,把它刪除。修改IndexController.php,為業(yè)務(wù)邏輯以添加相應(yīng)的action和一些注釋:
<?php
Zend::loadClass('Zend_Controller_Action');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
/* List the news. */
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
接下來,創(chuàng)建AddController.php文件:
<?php
Zend::loadClass('Zend_Controller_Action');
class AddController extends Zend_Controller_Action
{
function indexAction()
{
$this->_redirect('/');
}
function commentAction()
{
/* Add a comment. */
}
function newsAction()
{
/* Add news. */
}
function __call($action, $arguments)
{
$this->_redirect('/');
}
}
?>
記住AddController的indexAction()方法不能調(diào)用。當(dāng)訪問/add時會執(zhí)行這個類方法。因?yàn)橛脩艨梢允止ぴL問這個網(wǎng)址,這是有可能的,所以你要把用戶重定向到主頁、顯示錯誤或你認(rèn)為合適的行為。
接下來,創(chuàng)建AdminController.php文件:
<?php
Zend::loadClass('Zend_Controller_Action');
class AdminController extends Zend_Controller_Action
{
function indexAction()
{
/* Display admin interface. */
}
function approveAction()
{
/* Approve news. */
}
function __call($action, $arguments)
{
$this->_redirect('/');
}
}
?>
最后,創(chuàng)建ViewController.php文件:
<?php
Zend::loadClass('Zend_Controller_Action');
class ViewController extends Zend_Controller_Action
{
function indexAction()
{
$this->_redirect('/');
}
function __call($id, $arguments)
{
/* Display news and comments for $id. */
}
}
?>
和AddController一樣,index()方法不能調(diào)用,所以你可以使用你認(rèn)為合適的action。ViewController和其它的有點(diǎn)不同,因?yàn)槟悴恢朗裁床攀怯行У腶ction。為了支持像/view/23這樣的網(wǎng)址,你要使用__call()來支持動態(tài)action。
數(shù)據(jù)庫操作
因?yàn)閆end Framework的數(shù)據(jù)庫組件還不穩(wěn)定,而我希望這個演示可以做得簡單一點(diǎn)。我使用了一個簡單的類,用SQLite進(jìn)行新聞條目和評論的存儲和查詢。
<?php
class Database
{
private $_db;
public function __construct($filename)
{
$this->_db = new SQLiteDatabase($filename);
}
public function addComment($name, $comment, $newsId)
{
$name = sqlite_escape_string($name);
$comment = sqlite_escape_string($comment);
$newsId = sqlite_escape_string($newsId);
$sql = "INSERT
INTO comments (name, comment, newsId)
VALUES ('$name', '$comment', '$newsId')";
return $this->_db->query($sql);
}
public function addNews($title, $content)
{
$title = sqlite_escape_string($title);
$content = sqlite_escape_string($content);
$sql = "INSERT
INTO news (title, content)
VALUES ('$title', '$content')";
return $this->_db->query($sql);
}
public function approveNews($ids)
{
foreach ($ids as $id) {
$id = sqlite_escape_string($id);
$sql = "UPDATE news
SET approval = 'T'
WHERE id = '$id'";
if (!$this->_db->query($sql)) {
return FALSE;
}
}
return TRUE;
}
public function getComments($newsId)
{
$newsId = sqlite_escape_string($newsId);
$sql = "SELECT name, comment
FROM comments
WHERE newsId = '$newsId'";
if ($result = $this->_db->query($sql)) {
return $result->fetchAll();
}
return FALSE;
}
public function getNews($id = 'ALL')
{
$id = sqlite_escape_string($id);
switch ($id) {
case 'ALL':
$sql = "SELECT id,
title
FROM news
WHERE approval = 'T'";
break;
case 'NEW':
$sql = "SELECT *
FROM news
WHERE approval != 'T'";
break;
default:
$sql = "SELECT *
FROM news
WHERE id = '$id'";
break;
}
if ($result = $this->_db->query($sql)) {
if ($result->numRows() != 1) {
return $result->fetchAll();
} else {
return $result->fetch();
}
}
return FALSE;
}
}
?>
(你可以用自己的解決方案隨意替換這個類。這里只是為你提供一個完整示例的介紹,并非建議要這么實(shí)現(xiàn)。)
這個類的構(gòu)造器需要SQLite數(shù)據(jù)庫的完整路徑和文件名,你必須自己進(jìn)行創(chuàng)建。
<?php
$db = new SQLiteDatabase('/path/to/db.sqlite');
$db->query("CREATE TABLE news (
id INTEGER PRIMARY KEY,
title VARCHAR(255),
content TEXT,
approval CHAR(1) DEFAULT 'F'
)");
$db->query("CREATE TABLE comments (
id INTEGER PRIMARY KEY,
name VARCHAR(255),
comment TEXT,
newsId INTEGER
)");
?>
你只需要做一次,以后直接給出Database類構(gòu)造器的完整路徑和文件名即可:
<?php
$db = new Database('/path/to/db.sqlite');
?>
整合
為了進(jìn)行整合,在lib目錄下創(chuàng)建Database.php,loadClass()就可以找到它。你的index.php文件現(xiàn)在就會初始化$view和$db并存儲到寄存器。你也可以創(chuàng)建__autoload()函數(shù)自動加載你所需要的類:
<?php
include 'Zend.php';
function __autoload($class)
{
Zend::loadClass($class);
}
$db = new Database('/path/to/db.sqlite');
Zend::register('db', $db);
$view = new Zend_View;
$view->setScriptPath('/path/to/views');
Zend::register('view', $view);
$controller = Zend_Controller_Front::getInstance()
->setControllerDirectory('/path/to/controllers')
->dispatch();
?>
接下來,在views目錄創(chuàng)建一些簡單的模板。index.php可以用來顯示index視圖:
<html>
<head>
<title>News</title>
</head>
<body>
<h1>News</h1>
<?php foreach ($this->news as $entry) { ?>
<p>
<a href="/view/<?php echo $this->escape($entry['id']); ?>">
<?php echo $this->escape($entry['title']); ?>
</a>
</p>
<?php } ?>
<h1>Add News</h1>
<form action="/add/news" method="POST">
<p>Title:<br /><input type="text" name="title" /></p>
<p>Content:<br /><textarea name="content"></textarea></p>
<p><input type="submit" value="Add News" /></p>
</form>
</body>
</html>
view.php模板可以用來顯示選定的新聞條目:
<html>
<head>
<title>
<?php echo $this->escape($this->news['title']); ?>
</title>
</head>
<body>
<h1>
<?php echo $this->escape($this->news['title']); ?>
</h1>
<p>
<?php echo $this->escape($this->news['content']); ?>
</p>
<h1>Comments</h1>
<?php foreach ($this->comments as $comment) { ?>
<p>
<?php echo $this->escape($comment['name']); ?> writes:
</p>
<blockquote>
<?php echo $this->escape($comment['comment']); ?>
</blockquote>
<?php } ?>
<h1>Add a Comment</h1>
<form action="/add/comment" method="POST">
<input type="hidden" name="newsId"
value="<?php echo $this->escape($this->id); ?>" />
<p>Name:<br /><input type="text" name="name" /></p>
<p>Comment:<br /><textarea name="comment"></textarea></p>
<p><input type="submit" value="Add Comment" /></p>
</form>
</body>
</html>
最后,admin.php模板可以用來批準(zhǔn)新聞條目:
<html>
<head>
<title>News Admin</title>
</head>
<body>
<form action="/admin/approve" method="POST">
<?php foreach ($this->news as $entry) { ?>
<p>
<input type="checkbox" name="ids[]"
value="<?php echo $this->escape($entry['id']); ?>" />
<?php echo $this->escape($entry['title']); ?>
<?php echo $this->escape($entry['content']); ?>
</p>
<?php } ?>
<p>
Password:<br /><input type="password" name="password" />
</p>
<p><input type="submit" value="Approve" /></p>
</form>
</body>
</html>
提示:為了保持簡單,這個表單用密碼作為驗(yàn)證機(jī)制。
使用到模板的地方,你只需要把注釋替換成幾行代碼。如IndexController.php就變成下面這樣:
<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
/* List the news. */
$db = Zend::registry('db');
$view = Zend::registry('view');
$view->news = $db->getNews();
echo $view->render('index.php');
}
public function noRouteAction()
{
$this->_redirect('/');
}
}
?>
因?yàn)闂l理比較清楚,這個程序首頁的整個業(yè)務(wù)邏輯只有四行代碼。AddController.php更復(fù)雜一點(diǎn),它需要更多的代碼:
<?php
class AddController extends Zend_Controller_Action
{
function indexAction()
{
$this->_redirect('/');
}
function commentAction()
{
/* Add a comment. */
$filterPost = new Zend_InputFilter($_POST);
$db = Zend::registry('db');
$name = $filterPost->getAlpha('name');
$comment = $filterPost->noTags('comment');
$newsId = $filterPost->getDigits('newsId');
$db->addComment($name, $comment, $newsId);
$this->_redirect("/view/$newsId");
}
function newsAction()
{
/* Add news. */
$filterPost = new Zend_InputFilter($_POST);
$db = Zend::registry('db');
$title = $filterPost->noTags('title');
$content = $filterPost->noTags('content');
$db->addNews($title, $content);
$this->_redirect('/');
}
function __call($action, $arguments)
{
$this->_redirect('/');
}
}
?>
因?yàn)橛脩粼谔峤槐韱魏蟊恢囟ㄏ?,這個controller不需要視圖。
在AdminController.php,你要處理顯示管理界面和批準(zhǔn)新聞兩個action:
<?php
class AdminController extends Zend_Controller_Action
{
function indexAction()
{
/* Display admin interface. */
$db = Zend::registry('db');
$view = Zend::registry('view');
$view->news = $db->getNews('NEW');
echo $view->render('admin.php');
}
function approveAction()
{
/* Approve news. */
$filterPost = new Zend_InputFilter($_POST);
$db = Zend::registry('db');
if ($filterPost->getRaw('password') == 'mypass') {
$db->approveNews($filterPost->getRaw('ids'));
$this->_redirect('/');
} else {
echo 'The password is incorrect.';
}
}
function __call($action, $arguments)
{
$this->_redirect('/');
}
}
?>
最后是ViewController.php:
<?php
class ViewController extends Zend_Controller_Action
{
function indexAction()
{
$this->_redirect('/');
}
function __call($id, $arguments)
{
/* Display news and comments for $id. */
$id = Zend_Filter::getDigits($id);
$db = Zend::registry('db');
$view = Zend::registry('view');
$view->news = $db->getNews($id);
$view->comments = $db->getComments($id);
$view->id = $id;
echo $view->render('view.php');
}
}
?>
雖然很簡單,但我們還是提供了一個功能較全的新聞和評論程序。最好的地方是由于有較好的設(shè)計(jì),增加功能變得很簡單。而且隨著Zend Framework越來越成熟,只會變得更好。
更多信息
這個教程只是討論了ZF表面的一些功能,但現(xiàn)在也有一些其它的資源可供參考。在http://framework.zend.com/manual/有手冊可以查詢,Rob Allen在http://akrabat.com/zend-framework/介紹了一些他使用Zend Framework的經(jīng)驗(yàn),而Richard Thomas也在http://www.cyberlot.net/zendframenotes提供了一些有用的筆記。如果你有自己的想法,可以訪問Zend Framework的新論壇:http://www.phparch.com/discuss/index.php/f/289//。
結(jié)束語
要對預(yù)覽版進(jìn)行評價是很容易的事,我在寫這個教程時也遇到很多困難??偟膩碚f,我想Zend Framework顯示了承諾,加入的每個人都是想繼續(xù)完善它。
更多關(guān)于zend相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Zend FrameWork框架入門教程》、《php優(yōu)秀開發(fā)框架總結(jié)》、《Yii框架入門及常用技巧總結(jié)》、《ThinkPHP入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家基于Zend Framework框架的PHP程序設(shè)計(jì)有所幫助。
- Zend Framework 2.0事件管理器(The EventManager)入門教程
- Zend Framework數(shù)據(jù)庫操作技巧總結(jié)
- Zend Framework數(shù)據(jù)庫操作方法實(shí)例總結(jié)
- Zend Framework入門教程之Zend_Db數(shù)據(jù)庫操作詳解
- ZendFramework框架實(shí)現(xiàn)連接兩個或多個數(shù)據(jù)庫的方法
- Zend Framework教程之連接數(shù)據(jù)庫并執(zhí)行增刪查的方法(附demo源碼下載)
- Zend Framework連接Mysql數(shù)據(jù)庫實(shí)例分析
- 解析如何使用Zend Framework 連接數(shù)據(jù)庫
- zend framework配置操作數(shù)據(jù)庫實(shí)例分析
- windows下zendframework項(xiàng)目環(huán)境搭建(通過命令行配置)
- zend framework多模塊多布局配置
- ZendFramework2連接數(shù)據(jù)庫操作實(shí)例
相關(guān)文章
Laravel 6 將新增為指定隊(duì)列任務(wù)設(shè)置中間件的功能
這篇文章主要介紹了Laravel 6 將新增為指定隊(duì)列任務(wù)設(shè)置中間件的功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價值,需要的朋友可以參考下2019-08-08
php中配置文件保存修改操作 如config.php文件的讀取修改等操作
有時候我們需要用php將一些配置參數(shù)寫到文件里面,方便后期讀取使用,這里就為大家分享一下具體的實(shí)現(xiàn)代碼,需要的朋友可以參考一下2021-05-05
PHP判斷是手機(jī)端還是PC端 PHP判斷是否是微信瀏覽器
這篇文章主要為大家詳細(xì)介紹了PHP判斷是手機(jī)端還是PC端,以及PHP判斷是否是微信瀏覽器,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-03-03
PHP以json或xml格式返回請求數(shù)據(jù)的方法
今天小編就為大家分享一篇PHP以json或xml格式返回請求數(shù)據(jù)的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-05-05
在IIS7.0下面配置PHP 5.3.2運(yùn)行環(huán)境的方法
最近心血來潮,想學(xué)習(xí)一下php,既然想學(xué)習(xí)了就得需要搭環(huán)境。在網(wǎng)上找來找去都是說IIS5.0或者6.0的配置。真是看得云里霧里的,這樣直接影響了我的判斷力?,F(xiàn)特意寫下來在IIS7.0下面如何進(jìn)行配置PHP。2010-04-04
Thinkphp5+plupload實(shí)現(xiàn)的圖片上傳功能示例【支持實(shí)時預(yù)覽】
這篇文章主要介紹了Thinkphp5+plupload實(shí)現(xiàn)的圖片上傳功能,結(jié)合具體實(shí)例形式分析了thinkPHP5結(jié)合plupload實(shí)現(xiàn)可支持實(shí)時預(yù)覽的圖片上傳功能相關(guān)操作技巧,需要的朋友可以參考下2019-05-05
php把時間戳轉(zhuǎn)換成多少時間之前函數(shù)的實(shí)例
下面小編就為大家?guī)硪黄猵hp把時間戳轉(zhuǎn)換成多少時間之前函數(shù)的實(shí)例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-11-11-
最新評論

