PHP妗嗘灦 ZenTaoPHP_PHP鏁欑▼ | 甯涔嬪
ZenTaoPHP妗嗘灦鏄敱绂呴亾椤圭洰绠$悊杞欢寮€鍙戝洟闃熷紑鍙戠殑涓€娆捐交閲忕骇鐨凱HP寮€鍙戞鏋讹紝瀹冧富瑕佺殑鐗圭偣鏄細
1.1 浠g爜绠€鍗?br /> ZenTaoPHP妗嗘灦鏍稿績鍙湁鍥涗釜鏂囦欢锛屽垎鍒负璋冨害绫籸outer.class.php锛宑ontrol绫籧ontrol.class.php锛宮odel绫籱odel.class.php鍜屽伐鍏风被helper.class.php銆傞噷闈㈢殑浠g爜涔熻冻澶熺畝鍗曘€傝繖鏍峰ぇ瀹跺彲浠ュ緢瀹规槗鐨勮鎳傚畠鐨勪唬鐮侊紝骞舵牴鎹嚜宸辩殑瀹為檯搴旂敤杩涜瀹氬埗淇敼銆?/p>
1.2 鎬ц兘鑹ソ
ZenTaoPHP妗嗘灦鍦ㄥ疄鐜拌繃绋嬩腑锛屽崄鍒嗛噸瑙嗘€ц兘銆傚湪淇濊瘉鍔熻兘鐨勫墠鎻愪笅闈紝灏藉彲鑳界殑鎻愬崌绋嬪簭鎵ц鏁堢巼銆?/p>
1.3 缁撴瀯娓呮櫚
浣跨敤ZenTaoPHP妗嗘灦鏉ュ紑鍙戝簲鐢紝鍏剁洰褰曠粨鏋勭畝鍗曟竻鏅帮紝缁存姢璧锋潵闈炲父鐨勬柟渚裤€?/p>
1.4 寮€鍙戝弸濂?br /> 妗嗘灦锛岄鍏堟槸涓€涓锛屾妸浣犳鍦ㄤ簡閲岄潰銆傛墍浠ュ緢澶氭鏋朵細鏈夊緢澶氱殑绾﹀畾锛屼綘瑕佹€庢牱锛屼綘瑕佹€庢牱銆傝繕鏈夊緢澶氶殣褰㈢殑绾﹀畾锛屾瘮濡備綘瑕佸湪浣犵殑浠g爜閲岄潰鍐欏緢澶氱殑xxxx涔嬬被鐨勪笢涓溿€傛垜瑙夊緱涓€涓ソ鐨勬鏋跺湪瀹炵幇鍔熻兘鐨勫墠鎻愪笅锛屽簲褰撳敖閲忓吋椤惧紑鍙戜汉鍛樹箣鍓嶇殑寮€鍙戜範鎯€俍enTaoPHP妗嗘灦鍦ㄨ繖鏂归潰鑺变簡寰堝ぇ鐨勫姏姘旓細
- 涓€у懡鍚嶏細妗嗘灦瀹炵幇鏃讹紝娌℃湁鍑虹幇浠€涔坺entao涔嬬被鐨勫懡鍚嶏紝瀹屽叏鏄腑鎬х殑鍛藉悕锛歳outer, control, model, config, lang銆?/li>
- 閰嶇疆瀵硅薄鍖栵細 閰嶇疆椤瑰彲浠ラ€氳繃瀵硅薄鐨勬柟寮忔潵寮曠敤锛?config->db->user锛岃姣?config['db']['user']绠€娲侀『鐣呯殑澶氥€?/li>
- 鐩稿璺緞鍖呭惈锛氬湪ZenTaoPHP妗嗘灦寮€鍙戠殑搴旂敤涓紝鎵€鏈夌殑璺緞閮藉彲浠ョ敤鐩稿璺緞鏉ヨ繘琛屽寘鍚紝杩欐牱鍙互寰堟竻鏅扮殑鐭ラ亾鐩綍缁撴瀯鍜屼唬鐮佷箣闂寸殑鍏崇郴銆?/li>
1.5 public domain 鎺堟潈
public domain 鎺堟潈灏辨槸浣犲彲浠ユ嬁瀹冨仛浠讳綍鐨勪簨鎯咃紝绂呴亾寮€鍙戝洟闃熷凡缁忓皢ZenTaoPHP妗嗘灦鐨勭増鏉冨畬鍏ㄧ殑鎹愮尞缁欎簡鍏紬棰嗗煙銆備换浣曚汉锛屼换浣曞崟浣嶅彲浠ユ嬁瀹冨仛浠讳綍鐨勪簨鎯咃紝鑰屾病鏈変换浣曠殑闄愬埗銆?/p>
浜屻€乑enTaoPHP妗嗘灦鐨勪富瑕佸姛鑳藉涓嬶細
2.1 鍗曚竴鍏ュ彛妯″紡
鍗曚竴鍏ュ彛鏄幇鍦ㄦ瘮杈冩祦琛岀殑寮€鍙戞柟寮忋€傚ソ澶勫湪浜庡彲浠ユ湁涓€涓泦涓殑鎺у埗銆傛垨鑰呰妗嗘灦涓€涓瘮杈冨熀鏈殑涓滆タ涔熸槸鍗曚竴鍏ュ彛鍚с€傜幇鍦╖enTaoPHP妗嗘灦鏀寔web鏂瑰紡鍜屽懡浠よ鏂瑰紡鐨勪袱绉嶅叆鍙f枃浠躲€傚叿浣撶殑渚嬪瓙澶у鍙互鏌ョ湅app鐩綍涓嬮潰鐨刣emo/www/index.php鍜宑li/call杩欎袱涓枃浠躲€?/p>
2.2 MVC
ZenTaoPHP鏀寔MVC鏂瑰紡鐨勫紑鍙戙€備笉杩囩浉姣旇緝浜庡叾浠栨鏋剁殑澶氱妯℃澘瀹炵幇鏉ヨ锛孼enTaoPHP骞舵病鏈夊皾璇曞幓寮€鍙戜竴濂楁柊鐨勬ā鏉跨郴缁燂紝鑰屾槸閲囩敤PHP浣滀负妯℃澘璇█銆傝繖鏄渶蹇殑涓€绉嶈В鍐虫柟妗堬紝鑰屼笖涔熸槸鏈€绠€娲佺殑涓€绉嶆柟妗堛€?br />
2.3 鏀寔GET鍜孭ATH_INFO涓ょ鏂瑰紡璋冪敤
鏀寔 index.php?m=user&f=info&id=123杩欑GET鏂瑰紡鐨勮皟鐢紝涔熸敮鎸?/user/info/id/123.html 杩欑鏂瑰紡鐨勮皟鐢ㄣ€傚鏋滀綘鑳芥帶鍒朵綘鐨勮繍琛岀幆澧冿紝鍙互浣跨敤PATH_INFO鐨勬柟寮忥紝杩欐牱鐢熸垚鐨刄RL鍦板潃鏇村姞绠€鎹凤紝鑰屼笖瀵规悳绱㈠紩鎿庡崄鍒嗗弸濂姐€?br />
2.4 鍐呯疆鏁版嵁搴撹闂眰DAO
绂呴亾妗嗘灦鍐呯疆浜咲AO鏁版嵁搴撹闂眰锛屽湪PDO鐨勫熀纭€涓婏紝鎻愪緵浜嗗畬鏁寸殑SQL鎷艰鍔熻兘锛屽彲浠ラ潪甯告柟渚跨殑涔﹀啓SQL鏌ヨ璇彞锛岃幏鍙栨暟鎹€傝€屼笖鎴戜滑鍦ㄥ疄鐜癉AO鐨勬椂鍊欙紝鑺变簡寰堝ぇ鐨勫姏姘斿湪鍏煎涔嬪墠澶у鎵嬪啓SQL鐨勪範鎯紝鎵€浠ュぇ瀹跺湪浣跨敤绂呴亾妗嗘灦鐨凞AO鐨勬椂鍊欙紝浼氬彂鐜板緢浜插垏锛屽洜涓哄拰鎵嬪啓SQL鍩烘湰涓婃槸鐩稿悓鐨勩€?br />
2.5 鏀寔璺ㄦā鍧椾箣闂寸殑璋冪敤
鍦╖enTaoPHP妗嗘灦涓紝涓€涓ā鍧楃殑control鎴栬€卪odel閮藉彲浠ョ洿鎺ヨ皟鐢ㄥ彟澶栦竴涓ā鍧楃殑model锛岃繖鏍峰氨鍙互灏嗕竴涓簲鐢ㄨ繘琛屾ā鍧楀寲锛岀劧鍚庨€氳繃閲囩敤涓嶅悓妯″潡鐨勫姛鑳斤紝鏉ュ疄鐜版瘮杈冨鏉傜殑鍔熻兘銆?br />
闄や簡model鐨勮皟鐢ㄤ箣澶栵紝涓€涓ā鍧楃殑control杩樺彲浠etch鍙﹀涓€涓ā鍧楃殑control鏂规硶锛岃繖绉嶄竴鑸敤浜庝竴浜涘叡鐢ㄧ殑椤甸潰鍏冪礌锛屾瘮濡傛墦鍗颁竴涓悳绱㈣〃鍗曪紝鎴栬€呮墦鍗拌彍鍗曠瓑绛夈€傞€氳繃control涔嬮棿鐨勪簰鐩歌皟鐢紝瀹炵幇浠g爜鐨勫叡浜€?br />
2.6 鏃犻渶璺敱閰嶇疆锛屽嵆鍙幏寰楃畝鎹风殑URL
ZenTaoPHP妗嗘灦鎻愪緵浜嗙畝娲佺殑鍙傛暟浼犻€掓柟寮忋€傛瘮濡倁ser妯″潡鏈変竴涓猺ead鏂规硶锛岄渶瑕乮d鍜宯ame涓や釜鍙傛暟锛岄€氬父鐨凱ATH_INO涓簎ser/read/id/1/name/wwccss.html锛岃€孼enTaoPHP鏀寔user/read/1/wwccss.html鐨勫舰寮忥紝杩欐牱灏辩渷鐣ヤ簡鍙傛暟鍚嶇殑浼犻€掋€傝繖涓€鍒囷紝閮戒笉闇€瑕侀厤缃换浣曠殑璺敱锛岀洿鎺ラ€氳繃妗嗘灦鐨勫姛鑳藉氨鍙互鑾峰緱銆?br />
2.7 鐏垫椿鐨勬暟鎹獙璇佹満鍒?br />
绂呴亾PHP妗嗘灦鍐呯疆浜嗙伒娲荤殑鏁版嵁楠岃瘉鏈哄埗锛屽彲浠ュ疄鐜板鏁版嵁鐨勪慨姝e拰妫€鏌ワ紝浠g爜鏋佸叾绱у噾锛岀畝娲併€?br />
2.8 閰嶇疆鍜岃瑷€鍙互閫氳繃瀵硅薄鏂瑰紡寮曠敤
ZenTaoPHP妗嗘灦鐨勯厤缃病鏈夌敤浠€涔坕ni鏂囦欢锛屼篃娌℃湁鐢ㄤ粈涔坹aml鏂囦欢锛屼篃娌℃湁鐢╬hp鐨勬暟缁勶紝鑰屾槸鐩存帴鐢≒HP瀵硅薄鐨勫舰寮忋€傝繖鏍烽厤缃枃浠朵笉闇€瑕佽В鏋愶紝灏卞彲浠ョ洿鎺ヤ娇鐢紝鑰屼笖寮曠敤璧锋潵鍗佸垎鐨勬柟渚裤€傚舰濡?config->db->host鐨勮繖绉嶆柟寮忥紝鑰屼笉鏄?config['db']['host']鐨勮繖绉嶆柟寮忋€備功鍐欒捣鏉ヤ細闈炲父鐨勬祦鐣咃紒
2.9 鏂逛究鐨勫叏灞€鍙橀噺搴旂敤
鍦╖enTaoPHP妗嗘灦涓紝寮曠敤GET锛孭OST, SERVER杩欐牱鐨勫叏灞€鍙橀噺锛屽彲浠ラ€氳繃杩欐牱鐨勬柟寮忥細$this->get->userName, $this->post->userName, $this->server->remote_addr銆?br />
2.10 鎵€瑙佸嵆API
鍦ㄧ幇鍦ㄥ紑鏀惧钩鍙扮殑娼祦涓嬮潰锛屾湁涓€涓潪甯稿ソ鐨刟pi鏈哄埗鏄瘮杈冮噸瑕佺殑銆傚湪ZT涓紝姣忎竴涓帴鍙i兘鍙互鎴愪负api銆傝嚦浜巃pi鐨勬柟寮忥紝鏄€氳繃鍏惰闂殑鎵╁睍鍚嶆潵鍔犱互鍖哄垎銆傛瘮濡傚鏋滀綘璁块棶鐨勬槸user/read/id/123.html锛岄偅涔堣繑鍥炵殑鏄甯哥殑缃戦〉銆傚鏋滆闂殑鏄痷ser/read/id/123.json锛岄偅涔堣繑鍥炵殑灏辨槸json鏍煎紡鐨勬暟鎹€?br />
2.11 鍐呯疆澶氳瑷€鏀寔
ZT鏀寔澶氱璇█鍔熻兘锛屼細鑷姩鏍规嵁褰撳墠鐢ㄦ埛瀹㈡埛绔殑淇℃伅鏉ュ垽鏂娇鐢ㄤ綍绉嶈瑷€锛岃繖鏍峰彲浠ユ柟渚垮ぇ瀹跺紑鍙戝璇█鐨勫簲鐢ㄣ€?br />
2.12 寮哄ぇ鐨勬墿灞曟満鍒?br />
ZenTaoPHP妗嗘灦瀹炵幇浜嗗己澶х殑鎵╁睍鏈哄埗銆傞€氳繃杩欏鎵╁睍鏈哄埗锛屽仛瀹氬埗寮€鍙戝彲浠ヨ鏄交鑰屾槗涓撅紝鍐嶄篃涓嶇敤鎷呭績缁存姢澶氫釜鍒嗘敮甯︽潵鐨勭棝鑻︿簡銆?/p>