Subversion Repositories qbpwcf-lib(archive)

Rev

Rev 751 | Rev 791 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 liveuser 1
        QBPWCF, Quick Build PHP website Component base on Fedora Linux.
615 liveuser 2
    Copyright (C) 2015~2024 Min-Jhin,Chen
1 liveuser 3
 
4
    This file is part of QBPWCF.
5
 
6
    QBPWCF is free software: you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation, either version 3 of the License, or
9
    (at your option) any later version.
10
 
11
    QBPWCF is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
15
 
16
    You should have received a copy of the GNU General Public License
17
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
18
 
751 liveuser 19
檔案目錄結構:
1 liveuser 20
 
751 liveuser 21
cgi -dir
22
存放 cgi 格式的腳本檔案.
1 liveuser 23
 
751 liveuser 24
composer -dir
25
用來存放 composer 工具的地方
512 liveuser 26
 
751 liveuser 27
db -dir
28
存放需要使用資料庫的套件sql與寫入與讀取資料庫資料的方法.
565 liveuser 29
 
751 liveuser 30
etc -dir
31
存放設定檔的路徑
720 liveuser 32
 
751 liveuser 33
fonts -dir
34
存放字體的路徑
725 liveuser 35
 
751 liveuser 36
img -dir
37
用來存放圖片的地方
748 liveuser 38
 
772 liveuser 39
javaScript -dir
40
存放用來產生javaScript給外部瀏覽器使用的目錄
41
 
751 liveuser 42
json -dir
43
存放用來接受回應後只回傳json的頁面
744 liveuser 44
 
751 liveuser 45
lib -dir
46
存放本套件用到到函式庫
744 liveuser 47
 
751 liveuser 48
non-free-lib -dir
49
存放不開源或不得任意散布的函式庫
744 liveuser 50
 
751 liveuser 51
systemd -dir
52
存放 service 設定檔
744 liveuser 53
 
751 liveuser 54
tcpdf -dir
55
存放 tcdpf 套件的地方
744 liveuser 56
 
751 liveuser 57
tmp -dir
58
暫存目錄
743 liveuser 59
 
751 liveuser 60
unserialize -dir
61
unserialize post data then output json.
743 liveuser 62
 
751 liveuser 63
testCase -dir
64
爲存放測試案例的地方
728 liveuser 65
 
751 liveuser 66
usr -dir
67
放置 usr 目錄相關的檔案與目錄.
736 liveuser 68
 
751 liveuser 69
var -dir
70
存放執行中的資源,例如socket檔案.
733 liveuser 71
 
751 liveuser 72
webExtension -dir
73
存放 webExtension 的目錄
733 liveuser 74
 
751 liveuser 75
*.php
76
提供各種功能的php檔案
733 liveuser 77
 
751 liveuser 78
*-soap.php
79
提供各種soap服務的php檔案
728 liveuser 80
 
751 liveuser 81
由於版權關係,因此以下檔案需自行下載與安裝:
728 liveuser 82
 
751 liveuser 83
lib/bootstrap-3.3.6-dist
84
lib/jquery-2.2.2.min.js
85
lib/notify.min.js
86
lib/Chart.js
87
lib/ckeditor
88
lib/webrtc
89
lib/apache-hive
90
lib/glMatrix
91
non-free-lib/amchart/amcharts_3.18.6.free
92
non-free-lib/amchart/amcharts_3.19.6.free
93
non-free-lib/amchart/ammap_3.19.6.free
94
non-free-lib/amchart/amstockchart_3.19.6.free
728 liveuser 95
 
751 liveuser 96
如何使用GPL授權
97
http://www.gnu.org/licenses/gpl-howto.html
726 liveuser 98
 
751 liveuser 99
命名空間的宣告與使用
100
http://oomusou.io/php/php-namespace/
101
http://php.net/manual/en/language.namespaces.importing.php
725 liveuser 102
 
751 liveuser 103
該套件開發規範:
725 liveuser 104
 
751 liveuser 105
建議函式執行遇到錯誤時要加上回傳 $result["functionName"] 代表出錯的是哪個函式
106
取得當前執行的function,可用預先定義的 __FUNCTION__ .
107
參考資料來源:
108
http://php.net/manual/en/language.constants.predefined.php
725 liveuser 109
 
751 liveuser 110
各函式使用參數前,應當要先檢查參數是否為陣列,這樣可以避免,參數名稱使用錯誤的問題,無法debug.尤其當該函式只有一個參數時,若無該檢查機制,將會難以deBug.
725 liveuser 111
 
751 liveuser 112
作為對外部類別開放存取的函式,應該要宣告為public static function fName().
113
作為僅對類別自己存取的函式,應該要宣告為private static function fName().
725 liveuser 114
 
751 liveuser 115
建立含有參數的函式一開始的寫法可以如下:
725 liveuser 116
 
751 liveuser 117
function haveArgu(&conf){
725 liveuser 118
 
751 liveuser 119
	#初始化要回傳的結果
120
	$result=array();
723 liveuser 121
 
751 liveuser 122
	#取得當前執行的函數名稱
123
	$result["function"]=__FUNCTION__;
723 liveuser 124
 
751 liveuser 125
	#如果沒有參數
126
	if(func_num_args()==0){
721 liveuser 127
 
751 liveuser 128
		#設置執行失敗
129
		$result["status"]="false";
721 liveuser 130
 
751 liveuser 131
		#設置執行錯誤訊息
132
		$result["error"]="函數".$result["function"]."需要參數";
721 liveuser 133
 
751 liveuser 134
		#回傳結果
135
		return $result;
720 liveuser 136
 
751 liveuser 137
		}#if end
720 liveuser 138
 
751 liveuser 139
	/* 請依據實際狀況使用
140
	#涵式說明:
141
	#判斷當前環境為web還是cmd
142
	#回傳結果:
143
	#$result,"web"或"cmd"
144
	if(csInformation::getEnv()==="web"){
705 liveuser 145
 
751 liveuser 146
		#設置執行失敗
147
		$result["status"]="false";
714 liveuser 148
 
751 liveuser 149
		#設置執行錯誤訊息
150
		$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
717 liveuser 151
 
751 liveuser 152
		#回傳結果
153
		return $result;
717 liveuser 154
 
751 liveuser 155
		}#if end
156
	*/
717 liveuser 157
 
751 liveuser 158
	#取得參數
159
	$result["argu"]=$conf;
718 liveuser 160
 
751 liveuser 161
	#如果 $conf 不為陣列
162
	if(gettype($conf)!=="array"){
718 liveuser 163
 
751 liveuser 164
		#設置執行失敗
165
		$result["status"]="false";
717 liveuser 166
 
751 liveuser 167
		#設置執行錯誤訊息
168
		$result["error"][]="\$conf變數須為陣列形態";
714 liveuser 169
 
751 liveuser 170
		#如果傳入的參數為 null
171
		if(is_null($conf)){
714 liveuser 172
 
751 liveuser 173
			#設置執行錯誤訊息
174
			$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
714 liveuser 175
 
751 liveuser 176
			}#if end
714 liveuser 177
 
751 liveuser 178
		#回傳結果
179
		return $result;
711 liveuser 180
 
751 liveuser 181
		}#if end
711 liveuser 182
 
751 liveuser 183
	}
712 liveuser 184
 
751 liveuser 185
建立不含有必填參數的涵式一開始的寫法可以如下:
712 liveuser 186
 
751 liveuser 187
function noMustFilledArgu(&$conf){
712 liveuser 188
 
751 liveuser 189
	#初始化要回傳的結果
190
	$result=array();
712 liveuser 191
 
751 liveuser 192
	#取得當前執行的函數名稱
193
	$result["function"]=__FUNCTION__;
714 liveuser 194
 
751 liveuser 195
	/* 請依據實際狀況使用
196
	#涵式說明:
197
	#判斷當前環境為web還是cmd
198
	#回傳結果:
199
	#$result,"web"或"cmd"
200
	if(csInformation::getEnv()==="web"){
712 liveuser 201
 
751 liveuser 202
		#設置執行失敗
203
		$result["status"]="false";
712 liveuser 204
 
751 liveuser 205
		#設置執行錯誤訊息
206
		$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
711 liveuser 207
 
751 liveuser 208
		#回傳結果
209
		return $result;
711 liveuser 210
 
751 liveuser 211
		}#if end
212
	*/
711 liveuser 213
 
751 liveuser 214
	#取得參數
215
	$result["argu"]=$conf;
711 liveuser 216
 
751 liveuser 217
	#如果 $conf 不為陣列
218
	if(gettype($conf)!="array"){
711 liveuser 219
 
751 liveuser 220
		#設置執行失敗
221
		$result["status"]="false";
711 liveuser 222
 
751 liveuser 223
		#設置執行錯誤訊息
224
		$result["error"][]="\$conf變數須為陣列形態";
710 liveuser 225
 
751 liveuser 226
		#如果傳入的參數為 null
227
		if(is_null($conf)){
709 liveuser 228
 
751 liveuser 229
			#設置執行錯誤訊息
230
			$result["error"][]="\$conf變數不得為null,請檢查函數「".$result["function"]."」的參數設置有無正確!";
709 liveuser 231
 
751 liveuser 232
			}#if end
709 liveuser 233
 
751 liveuser 234
		#回傳結果
235
		return $result;
709 liveuser 236
 
751 liveuser 237
		}#if end
238
	}
709 liveuser 239
 
751 liveuser 240
建立不含參數的涵式一開始的寫法可以如下:
241
function noArgu(){
709 liveuser 242
 
751 liveuser 243
	#初始化要回傳的結果
244
	$result=array();
711 liveuser 245
 
751 liveuser 246
	#取得當前執行的函數名稱
247
	$result["function"]=__FUNCTION__;
708 liveuser 248
 
751 liveuser 249
	/* 請依據實際狀況使用
250
	#涵式說明:
251
	#判斷當前環境為web還是cmd
252
	#回傳結果:
253
	#$result,"web"或"cmd"
254
	if(csInformation::getEnv()=="web"){
707 liveuser 255
 
751 liveuser 256
		#設置執行失敗
257
		$result["status"]="false";
707 liveuser 258
 
751 liveuser 259
		#設置執行錯誤訊息
260
		$result["error"][]="函數 ".$result["function"]." 僅能在命令列環境下運行!";
706 liveuser 261
 
751 liveuser 262
		#回傳結果
263
		return $result;
706 liveuser 264
 
751 liveuser 265
		}#if end
266
	*/
705 liveuser 267
 
751 liveuser 268
	}
705 liveuser 269
 
751 liveuser 270
當有以下變數宣告時
271
$conf["A"]["B"]["a"]=123;
272
$conf["A"]["B"]["b"]=123;
273
$conf["A"]["B"]["c"]=123;
274
卸除$conf["A"]["B"]參數時,應卸除,$conf["A"],這樣才能卸除乾淨。
706 liveuser 275
 
751 liveuser 276
參數的陣列名稱,應儘量改用成$conf[a.b.c],而非$conf[a][b][c],這樣才能方便處理與應用。
705 liveuser 277
 
751 liveuser 278
若要撰寫要放到/usr/bin底下的執行檔可將原本的php code 用 php -r '' 包住,不用<?php ?>符號。
705 liveuser 279
 
751 liveuser 280
參考資料:
705 liveuser 281
 
751 liveuser 282
以下網址為google提供的javascript整合套件,據說比JQuery更省資源
283
https://developers.google.com/speed/libraries/devguide?hl=zh-tw
705 liveuser 284
 
751 liveuser 285
PHP 設計模式學習手冊 (Learning PHP Design Patterns)
286
http://www.tenlong.com.tw/items/9862767707?item_id=609455
705 liveuser 287
 
751 liveuser 288
Dependency Manager for PHP
289
https://getcomposer.org/
705 liveuser 290
 
751 liveuser 291
Autoloading Standard
292
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
705 liveuser 293
 
751 liveuser 294
取得函數所接受到的參數數量
295
http://php.net/manual/en/function.func-num-args.php