Subversion Repositories qbpwcf-lib(archive)

Rev

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