Aaron Huang
先聲明一件事
現在沒寫 PHP 了
...
投資有賺有賠,使用前請先詳閱公開說明書
Aaron Huang

•   Software Engineer @ Waveface

•   PHP , JavaScript , CoffeeScript , Python ...etc

•   github, twitter : @aar0ntw

•   plurk : @smoraa

•   Blog: http://blog.buginception.com
Slide


http://goo.gl/yTXv6
Live Demo
再讓我   一些別的
PHP Framework
五花八門,用的順手就好
為什麼要用 framework
PHP 很難寫
寫的好不容易
市場上每個人都說會寫
那為什麼還要用 PHP
那為什麼還要用 PHP

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

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

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

• 門檻低
• 好上手
• 誰都會寫(?)
• 資源豐富
過去種種,罄竹難書
目的

• 推廣
• 介紹
• 入門
• Yii php framework tutorial
 •   Intro

 •   MVC pattern

 •   Http request life cycle in yii

 •   Folder Structure

 •   Tools

• live demo
• Q &A
官方資源



•   http://www.yiiframework.com

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

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

• MVC 架構
Yii 是什麼

• MVC 架構
• 快速開發
Yii 是什麼

• MVC 架構
• 快速開發
• 高效率
@DHH
@DHH
Before finding Ruby, I spent about four years developing PHP web-applications
Yii


• 美籍華人 薛強   (@qiang1)



• Prado
No framework will last forever
Plain PHP Flow

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
Q &A

phpconf 2012 yii