創建應用目錄文件
我們在web的根目錄(/var/www或者其他地方)創建一個文件夾,命名為helloworld。將下載好的框架解壓并放到該應用目錄下。創建好的目錄結構如下:
/var/www/helloworld/wind/ 框架目錄 controller/ 應用控制器目錄,業務代碼放在該目錄下 controller/IndexController.php 默認訪問的應用控制器 template/ 頁面模板目錄 template/index.htm 模板文件 index.php 入口腳本文件 編輯入口腳本index.php在應用目錄下創建入口腳本index.php,它的主要工作是加載框架并啟動應用。代碼如下:
require_once (../../wind/Wind.php);Wind::application()->run();PS:當然也可以同時在index.php中設置錯誤級別,WIND_DEBUG模式等。相關內容后面會介紹
創建IndexController.php
在應用目錄下創建controller/目錄。controller目錄是windframework默認定義的應用控制器存放的目錄,我們也可以通過手動配置的方式來改變應用的訪問路徑。在我們創建的 controller/ 目錄下創建IndexController.php類文件。文件內容如下:
<?php/*** the last known user to change this file in the repository <$LastChangedBy: long.shi $>* @author Qiong Wu [email protected]>* @version $Id: IndexController.php 2806 2011-09-23 03:28:55Z long.shi $* @package*/class IndexController extends WindController {public function run() {echo hello world;}}?在windframework中文件名和類名是相同的,這一點有點類似于java。windframework提供了兩個應用控制器的類型‘WindSimpleController’,‘WindController’。在這里我們繼承自‘WindController’,這兩個應用控制器的區別,在后面會具體介紹。
運行
至此,我們的hello world 應用已經完成??焱ㄟ^瀏覽器訪問下我們的hello world吧:
http://localhost/helloworld/index.php新聞熱點
疑難解答