PHP 架構:Gaeaphp

來源:互聯網
上載者:User
Gaeaphp 是一個基於 flightphp 的 PHP 架構

基礎

環境要求

php 5.4+

安裝

  • WebServer,具體配置方法參見Flight按照要求

  • Php-Memcached擴充,具體配置方法參見pecl

結構設計

項目目錄結構

|-app/
| ?|-configs/ 設定檔夾
| ?|-bootstrap.php 引導檔案
|-src/ 代碼目錄
| ?|-libs/ 類庫方法庫
| ?| ?|-classes/
| ?| ?|-functions/
| ?|-modules/ 模組檔案夾
| ?| ?|-xxxmodules/
| ?| ?| ?|-controller/
| ?| ?| ?|-libs/
| ?| ?| ?|-model/
| ?|-templates/
| ?| ?|-default/
|-temp/ 臨時目錄
| ?|-caches/
| ?|-compiled/
| ?|-logs/

url訪問

架構採用mvc設計模式開發,採用單一入口方式部署和訪問。訪問樣本

http://yourdomain.com/module/controller/action/param1/param2

其中將會訪問

/src/module/controller.php下的action方法

引導檔案

/app/bootstrap.php引導檔案完成了命名空間的註冊,擴充模版引擎,以及路由的註冊。
其中常量定義:
ROOT_PATH?系統根目錄
APP_PATH?app目錄
TEMP_PATH?臨時目錄
SSRC_PATH ? 系統代碼目錄
WEB_PATH ? 系統WEB資來源目錄

系統配置

所有的設定檔均已數組形式返回。具體設定檔項在/app/configs下
|-db.php 資料庫(Mysql)設定檔
|-memcache.php 緩衝(Memcache)設定檔
|-route.php 路由設定檔
|-smarty.php 模版引擎設定檔
|-system.php 系統設定檔

系統配置

結構為一維數組,各項參數見注釋

return  array(    'theme'     =>      'default',   //主題    'debug'     =>      true,       //是否調試資訊    'log_level' =>      'DEBUG',    //日誌列印層級EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG    'cache_expire'  =>  3600,       //緩衝時間,單位秒    'prefix'  =>  'sobey_',   //儲存索引值首碼,包含db和cache);

資料庫配置

結構為二維數組,預設使用default,可參考default結構配置多個資料庫配置如test

return  array(    'default'   =>  array(            'database_type'=>'mysql',            'database_name'=>'ecshop',            'server'=>'127.0.0.1',            'username'=>'root',            'password'=>'123456',            //其他選擇性參數參見php手冊            //http://www.php.net/manual/en/pdo.setattribute.php            'port'=>3306    ),    //test配置非系統預設    'test'      =>  array(        //.........    ),);

Memcached配置

結構為二維數組,預設使用default,可參考default結構配置多個資料庫配置如test

return array(    'servers'=>array(        //array('網域名稱','連接埠','權重')     array('127.0.0.1','11211'),    ),    //options為Memcached::setOptions參數    'options'=>array(        //Memcached::OPT_HASH => Memcached::HASH_MURMUR,        //Memcached::OPT_PREFIX_KEY => "widgets"    ),);

smarty配置

結構為二維數組,預設使用default,可參考default結構配置多個資料庫配置如test

return array(    'servers'=>array(        //array('網域名稱','連接埠','權重')     array('127.0.0.1','11211'),    ),    'options'=>array(        //Memcached::OPT_HASH => Memcached::HASH_MURMUR,        //Memcached::OPT_PREFIX_KEY => "widgets"    ),);

模組modules

一個模組的基本結構為,請遵循以下的規則:
|-src/ 代碼目錄
| ?|-modules/ 模組檔案夾
| ?| ?|-xxxmodules/ 模組根目錄
| ?| ?| ?|-api/ 介面檔案目錄
| ?| ?| ?|-controller/ 控制器檔案夾 | ?| ?| ?|-libs/ 工具類庫
| ?| ?| ?|-model/ 模型類庫

項目

開發技巧

Core檔案

  • Core::config($file,[$key,[$dafault = false,[$reload = false]]]) 擷取設定檔

  • Core::load_func($func,[$path= '']) 載入函數

  • Core::log($module,$level,$message,[$context = array()]) 日誌記錄

  • Core::db([$key='default',[$option=array()]]) 擷取db執行個體

  • Core::memcached([$key='default',[$servers=array(),[$options=array()]]]) 擷取memcached執行個體

項目函數庫

一些項目的全域函數位於/src/libs/functions/global.php,該檔案會被自動載入。自己可建立模組的函數庫並使用Core::load_func()引入使用

模版

模版檔案位於: /src/teplate/{風格}/sso(模組)下,為smarty文法檔案。

項目首頁:http://www.open-open.com/lib/view/home/1429273546408

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.