Giáo trình Phát triển phần mềm mã nguồn mở - Bài 2: Zend Framework

Zend Framework Phát triển phần mềm mã nguồn mở Zend Framework 1. Thiết kế patterns 2. Thiết kế patterns theo MVC 3. Cấu trúc thư mục 4. Bootstrap 5. Ví dụ “Hello world” Thiết kế patterns Thiết kế pattern là giải pháp tái sử dụng cho một vấn đề xảy ra thường xuyên trong thiết kế phần mềm. (en.wikipedia.org/wiki/Design_pattern_(c omputer_science)) Thiết kế patterns theo MVC Model-View-Controller (MVC) là kiến trúc thiết kế theo các lớp: 1. Model: Tầng logic nghiệp vụ của một ứng d

pdf11 trang | Chia sẻ: huongnhu95 | Lượt xem: 428 | Lượt tải: 0download
Tóm tắt tài liệu Giáo trình Phát triển phần mềm mã nguồn mở - Bài 2: Zend Framework, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
ụng 2. View: Tầng liên quan đến giao diện ứng dụng. 3. Controller: Tầng controller gắn kết mọi lớp lại với nhau. Cấu trúc thư mục Bootstrap (index.php) “Hello world” với ZF MVC Vào đây: application/controllers/IndexController.php <? class IndexController extends Zend_Ctontroller_Action { public function indexAction() { } } ?> “Hello world” Sau đó vào đây: application/views/ Tạo file views/index/index.phtml Và nội dung: Hello world.. Tầng Models Vào application/models Viết thử <? class Math { public function __construct() { } public function sum($val1,$val2) { return $val1 + $val2; } } ?> Tầng Model Trong controller, gọi hàm sum lên <? class IndexController extends Zend_Ctontroller Action { public function indexAction() { $math = new Math(); $sum = $math->sum(5,10); $this->view->sum=$sum; } } ?> Tiếp tục ví dụ Cuối cùng trong tầng view(application/view/scripts/index/index.ph tml) Viết mã, <? echo ‘sum is ’ . $this->sum; ?>

Các file đính kèm theo tài liệu này:

  • pdfgiao_trinh_phat_trien_phan_mem_ma_nguon_mo_bai_2_zend_framew.pdf
Tài liệu liên quan