Basically, Yii(讀音: 易, Yes it is的縮寫)是個高性能PHP框架, 用來開發web 2.0應用。 用官網的話說叫快速, 安全, 專業。
在開始之前, 環境需要准備好。 具體點, 需要安裝PHP。 為了能開發基於DB的web應用, MySQL也需要安裝。 我的本地環境安裝了EasyPHP5.3(包含了web服務器, PHP, MySQL)。 同時本地也安裝有獨立的PHP5.4。 具體環境搭建一搜索一堆, 這裡略過。
要想快速建立一個web應用, 只需執行一個命令:
以下是命令輸出信息:
Create a Web application under 'C:\Progs\EasyPHP-5.3.9\www\testdrive'? (yes|no) [no]:y
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/assets
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/css
generate css/bg.gif
generate css/form.css
generate css/ie.css
generate css/main.css
generate css/print.css
generate css/screen.css
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/images
generate index-test.php
generate index.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected
generate protected/.htaccess
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/commands
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/commands/shell
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/components
generate protected/components/Controller.php
generate protected/components/UserIdentity.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/config
generate protected/config/console.php
generate protected/config/main.php
generate protected/config/test.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/controllers
generate protected/controllers/SiteController.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/data
generate protected/data/schema.mysql.sql
generate protected/data/schema.sqlite.sql
generate protected/data/testdrive.db
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/extensions
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/messages
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/migrations
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/models
generate protected/models/ContactForm.php
generate protected/models/LoginForm.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/runtime
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests
generate protected/tests/bootstrap.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests/fixtures
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests/functional
generate protected/tests/functional/SiteTest.php
generate protected/tests/phpunit.xml
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests/report
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/tests/unit
generate protected/tests/WebTestCase.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/views
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/views/layouts
generate protected/views/layouts/column1.php
generate protected/views/layouts/column2.php
generate protected/views/layouts/main.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/views/site
generate protected/views/site/contact.php
generate protected/views/site/error.php
generate protected/views/site/index.php
generate protected/views/site/login.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/protected/views/site/pages
generate protected/views/site/pages/about.php
generate protected/yiic
generate protected/yiic.bat
generate protected/yiic.php
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic/views
generate themes/classic/views/.htaccess
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic/views/layouts
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic/views/site
mkdir C:/Progs/EasyPHP-5.3.9/www/testdrive/themes/classic/views/system
Your application has been created successfully under C:\Progs\EasyPHP-5.3.9\www\testdrive.
其實到這裡, 應用已經建立完了。 下面啟動EasyPHP測試剛剛建立的應用, 看看是神馬樣子滴
猛然間讓我想起來Rails框架, 也是一個命令一個應用就出來了。 第一感覺涼爽.. 有繼續下去的勇氣了, 嘿嘿。 看看除了Home頁面還生成了啥:
Contact Login也有: