SlideShare a Scribd company logo
1 of 65
Yii Basic talk
 Aaron Huang - 黃冠中
About Aaron
•   a.k.a aar0ntw

•   Nexdoor Web Developer

•   Development , System Design , Training ...etc

•   PHP , JavaScript , Ruby , Python ...etc

•   github, twitter : @aar0ntw

•   plurk : @smoraa

•   Blog: http://blog.buginception.com
Agenda
• Yii php framework tutorial
 •   Intro

 •   MVC pattern

 •   Http request life cycle in yii

 •   Folder Structure

 •   Tools

• live demo
• Q &A
Slide


• http://www.slideshare.net/guanzhonghuang/
  presentations
官方資源



•   http://www.yiiframework.com

•   http://www.yiiframework.com/doc/api/1.1/

•   http://www.yiiframework.com/doc/guide/1.1/en/
簡介
Yii 是什麼
Yii 是什麼

• 是一個 PHP 的 web framework
Yii 是什麼

• 是一個 PHP 的 web framework
• 是一個 MVC 架構的 php framework
Yii 是什麼

• 是一個 PHP 的 web framework
• 是一個 MVC 架構的 php framework
• 是一個快速開發的 php framework
Yii 是什麼

• 是一個 PHP 的 web framework
• 是一個 MVC 架構的 php framework
• 是一個快速開發的 php framework
• 是一個高效率的 php framework
為什麼要用 framework
為什麼要用 framework
•   因為 PHP 很劣
為什麼要用 framework
•   因為 PHP 很劣

•   寫起來很醜
為什麼要用 framework
•   因為 PHP 很劣

•   寫起來很醜

•   看起來很散
為什麼要用 framework
•   因為 PHP 很劣

•   寫起來很醜

•   看起來很散

•    起來很怪
為什麼要用 framework
•   因為 PHP 很劣

•   寫起來很醜

•   看起來很散

•    起來很怪

•   因為很多人都說會寫 PHP
為什麼要用 framework
•   因為 PHP 很劣

•   寫起來很醜

•   看起來很散

•    起來很怪

•   因為很多人都說會寫 PHP

•   但實際上不太會寫。
那為什麼還要用 PHP
那為什麼還要用 PHP

• 門檻低
那為什麼還要用 PHP

• 門檻低
• 好上手
那為什麼還要用 PHP

• 門檻低
• 好上手
• 誰都會寫
那為什麼還要用 PHP

• 門檻低
• 好上手
• 誰都會寫
• 資源豐富
劣 即是 夯
需求
需求
• 介面的規範
需求
• 介面的規範
• 格式的標準
需求
• 介面的規範
• 格式的標準
• 程式碼的風格
需求
• 介面的規範
• 格式的標準
• 程式碼的風格
• 資料夾的結構
需求
• 介面的規範
• 格式的標準
• 程式碼的風格
• 資料夾的結構
• 開發者的紀律
常見 PHP 程式流程
index.php    about.php    page.php




access.php                 list.php




delete.php   update.php   create.php
Yii 程式流程
                                app
index.php      application
                             component




               controller




                 widget



 model                         view
差異
差異
• 介面化
差異
• 介面化
• 易於維護
差異
• 介面化
• 易於維護
• 程式耦合性低
差異
• 介面化
• 易於維護
• 程式耦合性低
• 結構清楚
差異
• 介面化
• 易於維護
• 程式耦合性低
• 結構清楚
• 容易預期
MVC 模式
MVC 模式


• Model - View - Controller
MVC 模式


• Model - View - Controller
• 資料 - 畫面 - 中介控制
MVC 模式


• Model - View - Controller
• 資料 - 畫面 - 中介控制
• 商業邏輯 - 前端畫面 - 流程控管
Yii request 生命週期
index.php (Bootstrap)
                               app
  index.php   application
                            component




              controller




                widget



   model                      view
Yii::CWebApplication
                               app
  index.php   application
                            component




              controller




                widget



   model                      view
Yii::CComponent
                             app
index.php   application
                          component




            controller




              widget



 model                      view
Yii::CUrlManager
                                          app
index.php   application
                                       component

                          UrlManager



            controller




              widget



 model                                   view
Yii::CController
                             app
index.php   application
                          component




            controller




              widget



 model                      view
Yii::CActiveRecord
                              app
 index.php   application
                           component




             controller




               widget



  model                      view
CController::render
                               app
  index.php   application
                            component




              controller




                widget



   model                      view
Yii::CWidget
                             app
index.php   application
                          component




            controller




              widget



 model                      view
實際開發
資料夾結構
輔助工具
輔助工具



• yiic : command line tool
輔助工具



• yiic : command line tool
• Gii : Web UI tool
輔助工具 : CLI tool
輔助工具 : CLI tool

• yiic shell
輔助工具 : CLI tool

• yiic shell
 • model
輔助工具 : CLI tool

• yiic shell
 • model
 • controller
輔助工具 : CLI tool

• yiic shell
 • model
 • controller
 • crud
輔助工具 : CLI tool

• yiic shell
 • model
 • controller
 • crud
• yiic migrate
Live Demo
Q &A


你問,我盡量答
謝謝大家

More Related Content

Similar to Yiitalk

twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸twMVC
 
国际图象互操作框架(IIIF) APIs和应用实例
国际图象互操作框架(IIIF)  APIs和应用实例 国际图象互操作框架(IIIF)  APIs和应用实例
国际图象互操作框架(IIIF) APIs和应用实例 Marcia Zeng
 
[DCTPE2010] 如何開發 CCK 欄位模組
[DCTPE2010] 如何開發 CCK 欄位模組[DCTPE2010] 如何開發 CCK 欄位模組
[DCTPE2010] 如何開發 CCK 欄位模組Drupal Taiwan
 
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練32015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3Duran Hsieh
 
向jquery学习
向jquery学习向jquery学习
向jquery学习jay li
 
美团前端架构简介
美团前端架构简介美团前端架构简介
美团前端架构简介pan weizeng
 
Real World ASP.NET MVC
Real World ASP.NET MVCReal World ASP.NET MVC
Real World ASP.NET MVCjeffz
 
Continuous integration
Continuous integrationContinuous integration
Continuous integrationnetdbncku
 
Angular js twmvc#17
Angular js twmvc#17Angular js twmvc#17
Angular js twmvc#17twMVC
 
学习 CodeIgniter
学习 CodeIgniter学习 CodeIgniter
学习 CodeIgniterBruceWolf
 
Uliweb cheat sheet_0.1
Uliweb cheat sheet_0.1Uliweb cheat sheet_0.1
Uliweb cheat sheet_0.1modou li
 
twMVC#31網站上線了然後呢
twMVC#31網站上線了然後呢twMVC#31網站上線了然後呢
twMVC#31網站上線了然後呢twMVC
 
大话Php之性能
大话Php之性能大话Php之性能
大话Php之性能liqiang xu
 
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式Justin Lin
 
系統整合
系統整合系統整合
系統整合麒 王
 
2011 php技术高峰论坛演讲.黄波
2011 php技术高峰论坛演讲.黄波2011 php技术高峰论坛演讲.黄波
2011 php技术高峰论坛演讲.黄波leontb
 
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例Will Huang
 
How to ASP.NET MVC4
How to ASP.NET MVC4How to ASP.NET MVC4
How to ASP.NET MVC4Daniel Chou
 
Continuous Delivery: automated testing, continuous integration and continuous...
Continuous Delivery: automated testing, continuous integration and continuous...Continuous Delivery: automated testing, continuous integration and continuous...
Continuous Delivery: automated testing, continuous integration and continuous...Jimmy Lai
 

Similar to Yiitalk (20)

twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸twMVC#01 | ASP.NET MVC 的第一次親密接觸
twMVC#01 | ASP.NET MVC 的第一次親密接觸
 
国际图象互操作框架(IIIF) APIs和应用实例
国际图象互操作框架(IIIF)  APIs和应用实例 国际图象互操作框架(IIIF)  APIs和应用实例
国际图象互操作框架(IIIF) APIs和应用实例
 
[DCTPE2010] 如何開發 CCK 欄位模組
[DCTPE2010] 如何開發 CCK 欄位模組[DCTPE2010] 如何開發 CCK 欄位模組
[DCTPE2010] 如何開發 CCK 欄位模組
 
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練32015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
2015 年逢甲大學資訊系:ASP.NET MVC 4 教育訓練3
 
向jquery学习
向jquery学习向jquery学习
向jquery学习
 
美团前端架构简介
美团前端架构简介美团前端架构简介
美团前端架构简介
 
Real World ASP.NET MVC
Real World ASP.NET MVCReal World ASP.NET MVC
Real World ASP.NET MVC
 
Continuous integration
Continuous integrationContinuous integration
Continuous integration
 
Angular js twmvc#17
Angular js twmvc#17Angular js twmvc#17
Angular js twmvc#17
 
使用 Controller
使用 Controller使用 Controller
使用 Controller
 
学习 CodeIgniter
学习 CodeIgniter学习 CodeIgniter
学习 CodeIgniter
 
Uliweb cheat sheet_0.1
Uliweb cheat sheet_0.1Uliweb cheat sheet_0.1
Uliweb cheat sheet_0.1
 
twMVC#31網站上線了然後呢
twMVC#31網站上線了然後呢twMVC#31網站上線了然後呢
twMVC#31網站上線了然後呢
 
大话Php之性能
大话Php之性能大话Php之性能
大话Php之性能
 
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
Servlet & JSP 教學手冊第二版 - 第 1 章:簡介Web應用程式
 
系統整合
系統整合系統整合
系統整合
 
2011 php技术高峰论坛演讲.黄波
2011 php技术高峰论坛演讲.黄波2011 php技术高峰论坛演讲.黄波
2011 php技术高峰论坛演讲.黄波
 
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
使用 TypeScript 駕馭 Web 世界的脫韁野馬:以 Angular 2 開發框架為例
 
How to ASP.NET MVC4
How to ASP.NET MVC4How to ASP.NET MVC4
How to ASP.NET MVC4
 
Continuous Delivery: automated testing, continuous integration and continuous...
Continuous Delivery: automated testing, continuous integration and continuous...Continuous Delivery: automated testing, continuous integration and continuous...
Continuous Delivery: automated testing, continuous integration and continuous...
 

More from Aaron Huang

More from Aaron Huang (6)

Scrumban
ScrumbanScrumban
Scrumban
 
Dollar symbol
Dollar symbolDollar symbol
Dollar symbol
 
Git branching-model
Git branching-modelGit branching-model
Git branching-model
 
Pomodoro
PomodoroPomodoro
Pomodoro
 
Apprenticeship Patterns
Apprenticeship PatternsApprenticeship Patterns
Apprenticeship Patterns
 
Readability
ReadabilityReadability
Readability
 

Yiitalk

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n