Rev 846 | Blame | Compare with Previous | Last modification | View Log | RSS feed
QBPWCF, Quick Build PHP website Component base on Fedora Linux.Copyright (C) 2015~2025 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/>.檔案目錄結構:usr/${folderOfUsrLib}/qbpwcf/cgi -dir存放 cgi 格式的腳本檔案.usr/${folderOfUsrLib}/qbpwcf/composer -dir用來存放 composer 工具的地方usr/${folderOfUsrLib}/qbpwcf/db -dir存放需要使用資料庫的套件sql與寫入與讀取資料庫資料的方法.etc/qbpwcf -dir存放設定檔的路徑usr/${folderOfUsrLib}/qbpwcf/fonts -dir存放字體的路徑usr/${folderOfUsrLib}/qbpwcf/img -dir用來存放圖片的地方usr/${folderOfUsrLib}/qbpwcf/javaScript -dir存放用來產生javaScript給外部瀏覽器使用的目錄usr/${folderOfUsrLib}/qbpwcf/json -dir存放用來接受回應後只回傳json的頁面usr/${folderOfUsrLib}/qbpwcf -dir存放本套件用到到函式庫usr/${folderOfUsrLib}/qbpwcf/non-free-lib -dir存放不開源或不得任意散布的函式庫etc/systemd/system -dir存放 service 設定檔usr/${folderOfUsrLib}/qbpwcf/tcpdf -dir存放 tcdpf 套件的地方var/qbpwcf/tmp -dir暫存目錄usr/${folderOfUsrLib}/qbpwcf/unserialize -dirunserialize post data then output json.usr/${folderOfUsrLib}/qbpwcf/testCase -dir爲存放舊版本測試案例的地方,預計會移除之.usr -dir放置 usr 目錄相關的檔案與目錄.var -dir存放執行中的資源,例如socket檔案、暫存檔案.usr/${folderOfUsrLib}/qbpwcf/webExtension -dir存放 webExtension 的目錄usr/${folderOfUsrLib}/qbpwcf/*.php提供各種功能的php檔案usr/${folderOfUsrLib}/qbpwcf/*-soap.php提供各種soap服務的php檔案sample -dir提供各類別底下個別函式的執行範例gpl.txtGPL條款說明index.php顯示 Release Note 檔案內容的頁面install.php安裝本套件的php腳本License版權宣告README本文件Release Note版本異動記錄由於版權關係,因此以下檔案需自行下載與安裝:usr/${folderOfUsrLib}/qbpwcf/lib/bootstrap-3.3.6-distusr/${folderOfUsrLib}/qbpwcf/lib/jquery-2.2.2.min.jsusr/${folderOfUsrLib}/qbpwcf/lib/notify.min.jsusr/${folderOfUsrLib}/qbpwcf/lib/Chart.jsusr/${folderOfUsrLib}/qbpwcf/lib/ckeditorusr/${folderOfUsrLib}/qbpwcf/lib/webrtcusr/${folderOfUsrLib}/qbpwcf/lib/apache-hiveusr/${folderOfUsrLib}/qbpwcf/lib/glMatrixusr/${folderOfUsrLib}/qbpwcf/non-free-lib/amchart/amcharts_3.18.6.freeusr/${folderOfUsrLib}/qbpwcf/non-free-lib/amchart/amcharts_3.19.6.freeusr/${folderOfUsrLib}/qbpwcf/non-free-lib/amchart/ammap_3.19.6.freeusr/${folderOfUsrLib}/qbpwcf/non-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().建立含有參數的函式一開始的寫法可以如下:/*#函式說明:#...#回傳結果:#$result["status"],"true"代表移除成功,"false"代表移除失敗.#$result["error"],錯誤訊息陣列.#$result["function"],當前執行的函數名稱.#$result["content"],主要期望的回傳內容.#必填參數:#$conf["key"],字串,名為"key"的參數.$conf["key"]="";#$conf["fileArgu"],字串,__FILE__的內容.$conf["fileArgu"]=__FILE__;#可省略參數:#無#參考資料:#無.#備註:#無*/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 haveArgu 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 ?>符號。建立 usr/bin 底下的程式時,建議開頭要先取得 lib 的路徑,可以放置以下 內容:#使用命名空間qbpwcfnamespace qbpwcf;#取得 lib pathexec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/libexec/folderOfUsrLib.php"),$output,$status);#如果執行失敗if($status!==0){#debugvar_dump(__LINE__,$output);#結束執行,回傳shell 1.exit(1);}#if end#儲存lib path$folderOfUsrLib=$output[0];#以該檔案的實際位置的 lib path 為 include path 首位$output=array();exec("cd ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../".$folderOfUsrLib."/qbpwcf").";pwd;",$output,$status);#如果執行失敗if($status!==0){#debugvar_dump(__LINE__,$output);#結束執行,回傳shell 1.exit(1);}#if end#設置 include pathset_include_path($output[0].PATH_SEPARATOR.get_include_path());#匯入外部套件include("allInOne.php");建立 usr/bin/libexec 底下的非 folderOfUsrLib.php 程式時,建議開頭要先取得 lib 的路徑,可以放置以下 內容:#使用命名空間qbpwcfnamespace qbpwcf;#取得 lib pathexec("php -f ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/folderOfUsrLib.php"),$output,$status);#如果執行失敗if($status!==0){#debugvar_dump($cmd,$ouput,$status);#結束執行,回傳shell 1.exit(1);}#if end#儲存lib path$folderOfUsrLib=$output[0];#以該檔案的實際位置的 lib path 為 include path 首位exec("cd ".escapeshellarg(pathinfo(__FILE__)["dirname"]."/../../".$folderOfUsrLib."/qbpwcf);pwd;",$output,$status);set_include_path($output[0].PATH_SEPARATOR.get_include_path());#匯入外部套件include("allInOne.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