Archive

‘Zend Framework’ 分類過的Archive

Yii VS Zend Framework 效能測試

2009年4月26日 3 則評論

Yii 的官方網站上面有展示了以 Hello World 產生簡單頁面所做的效能比較 , 看到之後當然是驚為天人 , 但這個測試只能得知在 Controller 到 View 之間頁面生成速度 , Yii 確實是快的不像話

由於要幫公司重新設計專案 , 要求的是效能 , 但又要好維護 , 若單以 Hello World 為測試基準可能不是很客觀 , 所以我就想說來自己加一些測試的程式碼 , 我寫了一個簡單的 Hello World 與留言板的列表 , 由於大部分的網頁應用除了 View 的頁面產生佔很大的 Loading , 再來就是 DataBase 的 Fetch 速度了

閱讀全文…

Categories: Yii, Zend Framework, 不分類 Tags:

Zend_View 的 helper headTitle() 很好用

2008年12月3日 尚無評論

以下介紹如何用 headTitle() 控制 HTML <title>標籤的內容 若 Layout Script 長的如下
 

1
2
3
4
5
6
7
8
9
10
11
<html>
<head>
<?php
    $this->headTitle()->setSeparator("/");
    $this->headTitle("我的網站" , 
           Zend_View_Helper_Placeholder_Container_Abstract::PREPEND);
    echo $this->headTitle();
?>
</head>
<body>...</body> 
</html>

閱讀全文…

Categories: Zend Framework Tags:

ContentSwitch 輸出 JSON 範例

2008年11月30日 尚無評論

Zend Framework 的 Zend_Controller_Action 下有個 Helper contextSwitch , 這個 Helper 可以用來切換 view 不同的輸出格式 , 假設我們有個 Controller 習慣用這方式產生網頁

class FooController extends Zend_Controller_Action {
	function barAction() {
		$this->view->assign("message" , "Hello World !");
	}
}

閱讀全文…

Categories: Zend Framework Tags:

Zend_Layout 與 ActionStack 結合很美 !

2008年11月15日 2 則評論

假設有一段 layout script 內容是

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

上面的 meuu 內容假設是會照資料庫而抓出動態選單 , 可以另外寫個 Controller 來作 , 例如 MenuController class MenuController extend Zend_Controller_Action {

extend Zend_Controller_Action {
	function indexAction() {
		/* 呼叫一些資料庫指令也 assign 一些東西給 viewscript  */
		$this->_helper->viewRenderer->setResponseSegment('menu');
	}
}

閱讀全文…

Categories: Zend Framework Tags:

用 Zend_Db_Select 處理分頁的資料 Query

2008年5月31日 尚無評論

假設我們有個 table 叫 products , 我們建立一個 class 繼承 Zend_Db_Table 如下

class ProductsModel extends Zend_Db_Table {
    protected $_name = ‘products’ ;
}

相信會用 Zend_Db_Table 的知道這是什麼物件幹什用的吧 !

若要一次抓出每頁 20 筆資料 , 可能我們會這麼做

閱讀全文…

Categories: Zend Framework Tags:

Zend_Layout 使用心得

2008年5月18日 尚無評論

Zend Framework 在 1.5 版尚未發布之前 , 要做 MVC 是使用 Zend_View 來將 View 部分獨立開來的 , 其實有使用過 Smarty 的老手應該也覺得 Zend_View 其實沒什新意 , 就是很簡單的 variable assign 而已 ….

當 Zend Framework 1.5 出來之後 , 新增了一個元件叫 Zend_Layout , 這個物件是為了解決版面佈局的問題 , 但這樣解釋應該會有人不懂 , 為何需要解決版面佈局問題 ?

閱讀全文…

Categories: Zend Framework Tags: