Rev 748 | Rev 772 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
QBPWCF, Quick Build PHP website Component base on Fedora Linux.Copyright (C) 2015~2024 Min-Jhin,ChenThis file is part of QBPWCF.QBPWCF is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.QBPWCF is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with QBPWCF. If not, see <http://www.gnu.org/licenses/>.檔案目錄結構:cgi -dir存放 cgi 格式的腳本檔案.composer -dir用來存放 composer 工具的地方db -dir存放需要使用資料庫的套件sql與寫入與讀取資料庫資料的方法.etc -dir存放設定檔的路徑fonts -dir存放字體的路徑img -dir用來存放圖片的地方json -dir存放用來接受回應後只回傳json的頁面lib -dir存放本套件用到到函式庫non-free-lib -dir存放不開源或不得任意散布的函式庫systemd -dir存放 service 設定檔tcpdf -dir存放 tcdpf 套件的地方tmp -dir暫存目錄unserialize -dirunserialize post data then output json.testCase -dir爲存放測試案例的地方usr -dir放置 usr 目錄相關的檔案與目錄.var -dir存放執行中的資源,例如socket檔案.webExtension -dir存放 webExtension 的目錄*.php提供各種功能的php檔案*-soap.php提供各種soap服務的php檔案由於版權關係,因此以下檔案需自行下載與安裝:lib/bootstrap-3.3.6-distlib/jquery-2.2.2.min.jslib/notify.min.jslib/Chart.jslib/ckeditorlib/webrtclib/apache-hivelib/glMatrixnon-free-lib/amchart/amcharts_3.18.6.freenon-free-lib/amchart/amcharts_3.19.6.freenon-free-lib/amchart/ammap_3.19.6.freenon-free-lib/amchart/amstockchart_3.19.6.free如何使用GPL授權http://www.gnu.org/licenses/gpl-howto.html命名空間的宣告與使用http://oomusou.io/php/php-namespace/http://php.net/manual/en/language.namespaces.importing.php該套件開發規範:建議函式執行遇到錯誤時要加上回傳 $result["functionName"] 代表出錯的是哪個函式取得當前執行的function,可用預先定義的 __FUNCTION__ .參考資料來源:http://php.net/manual/en/language.constants.predefined.php各函式使用參數前,應當要先檢查參數是否為陣列,這樣可以避免,參數名稱使用錯誤的問題,無法debug.尤其當該函式只有一個參數時,若無該檢查機制,將會難以deBug.作為對外部類別開放存取的函式,應該要宣告為public static function fName().作為僅對類別自己存取的函式,應該要宣告為private static function fName().建立含有參數的函式一開始的寫法可以如下:function haveArgu(&conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;#如果沒有參數if(func_num_args()==0){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"]="函數".$result["function"]."需要參數";#回傳結果return $result;}#if end/* 請依據實際狀況使用#涵式說明:#判斷當前環境為web還是cmd#回傳結果:#$result,"web"或"cmd"if(csInformation::getEnv()==="web"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";#回傳結果return $result;}#if end*/#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!=="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif(is_null($conf)){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end}建立不含有必填參數的涵式一開始的寫法可以如下:function noMustFilledArgu(&$conf){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;/* 請依據實際狀況使用#涵式說明:#判斷當前環境為web還是cmd#回傳結果:#$result,"web"或"cmd"if(csInformation::getEnv()==="web"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";#回傳結果return $result;}#if end*/#取得參數$result["argu"]=$conf;#如果 $conf 不為陣列if(gettype($conf)!="array"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="\$conf變數須為陣列形態";#如果傳入的參數為 nullif(is_null($conf)){#設置執行錯誤訊息$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";}#if end#回傳結果return $result;}#if end}建立不含參數的涵式一開始的寫法可以如下:function noArgu(){#初始化要回傳的結果$result=array();#取得當前執行的函數名稱$result["function"]=__FUNCTION__;/* 請依據實際狀況使用#涵式說明:#判斷當前環境為web還是cmd#回傳結果:#$result,"web"或"cmd"if(csInformation::getEnv()=="web"){#設置執行失敗$result["status"]="false";#設置執行錯誤訊息$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";#回傳結果return $result;}#if end*/}當有以下變數宣告時$conf["A"]["B"]["a"]=123;$conf["A"]["B"]["b"]=123;$conf["A"]["B"]["c"]=123;卸除$conf["A"]["B"]參數時,應卸除,$conf["A"],這樣才能卸除乾淨。參數的陣列名稱,應儘量改用成$conf[a.b.c],而非$conf[a][b][c],這樣才能方便處理與應用。若要撰寫要放到/usr/bin底下的執行檔可將原本的php code 用 php -r '' 包住,不用<?php ?>符號。參考資料:以下網址為google提供的javascript整合套件,據說比JQuery更省資源https://developers.google.com/speed/libraries/devguide?hl=zh-twPHP 設計模式學習手冊 (Learning PHP Design Patterns)http://www.tenlong.com.tw/items/9862767707?item_id=609455Dependency Manager for PHPhttps://getcomposer.org/Autoloading Standardhttps://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md取得函數所接受到的參數數量http://php.net/manual/en/function.func-num-args.php