Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time

鏂囨。杈撳嚭

1. Swagger 鏂囨。

Swagger 鏄祦琛岀殑 HTTP API 鎻忚堪瑙勮寖锛屽悓鏃 Swagger 瀹樻柟杩樻彁渚涗簡涓板瘜鐨勫伐鍏凤紝姣斿鐢ㄤ簬鏂囨。灞曠ず鍜屾帴鍙f祴璇曠殑 Swagger UI锛 鐩稿叧璧勬枡璇烽槄璇瀹樻柟鏂囨。

浠 phpboot-example 涓轰緥锛岀敓鎴愮殑鏂囨。濡備笅銆傛枃妗d腑闄や簡鎻忚堪浜嗘帴鍙g殑璺敱銆佸弬鏁板畾涔夈佸弬鏁版牎楠岋紝杩樻彁渚涗簡鎺ュ彛娴嬭瘯宸ュ叿銆鐐瑰嚮杩欓噷鏌ョ湅鍦ㄧ嚎 Demo

PhpBoot 椤圭洰鍙互寰堟柟渚跨殑鐢熸垚 Swagger 鏂囨。锛屾棤闇娣诲姞棰濆鐨 Annotation锛堝緢澶氭鏋朵负鏀寔 Swagger锛岄氬父闇瑕佸鍔犲緢澶氶澶栫殑娉ㄩ噴锛岃岃繖浜涙敞閲婂彧鐢ㄤ簬 Swagger銆侾hpBoot 鐢熸垚 Swagger 鐨勪俊鎭潵鑷矾鐢辩殑鏍囧噯娉ㄩ噴锛屽寘鎷珸route, @param, @return锛孈throws 绛夛級

濡傞渶寮鍚 Swagger 鏂囨。锛屽彧闇鍦ㄥ湪 Application 鍒濆鍖栨椂 娣诲姞浠ヤ笅浠g爜锛

PhpBoot\Docgen\Swagger\SwaggerProvider::register($app , function(Swagger $swagger){
    $swagger->host = 'example.com';
    $swagger->info->description = 'this is the description of the apis';
    ...
});

鐒跺悗璁块棶浣犵殑椤圭洰 url+/docs/swagger.json濡( http://localhost/docs/swagger.json)锛屽嵆鍙幏鍙 json 鏍煎紡鐨 Swagger 鏂囨。銆

2. MarkDown 鏂囨。

寮鍙戜腑...