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

Annotation

PhpBoot 妗嗘灦杈冨鐨勪娇鐢ㄤ簡 Annotation銆傚綋鐒跺師鐢 PHP 璇█骞朵笉鏀寔姝ら」鐗规э紝鎵浠ュ疄闄呮槸閫氳繃Reflection鎻愬彇娉ㄩ噴骞惰В鏋愬疄鐜帮紝绫讳技寰堝涓绘祦 PHP 妗嗘灦鐨勫仛娉曪紙濡 symfony銆乨octrine 绛夛級銆備絾鍙堟湁鎵涓嶅悓鐨勬槸锛屼富娴佺殑Annotation 璇硶鍩烘湰娌跨敤浜 java 涓殑褰㈠紡锛屽锛

/**
 * @Route("/books/{id}", name="book_info")
 * @Method("GET")
 */
 public function getBook($id)...

璇硶涓ヨ皑锛屾槗浜庢墿灞曪紝浣嗙◢鏄惧暟鍡(PhpBoot 1.x 鐗堟湰涔熶娇鐢ㄦ璇硶)銆傜壒鍒槸PHP 鐢变簬鍏堝ぉ涓嶈冻锛堝師鐢熶笉鏀寔Annotation锛夛紝閫氳繃娉ㄩ噴锛屽湪娌℃湁IDE璇硶鎻愮ず鍜岃繍琛屾椂妫鏌ユ満鍒剁殑鎯呭喌涓嬨傚鏋滃啓 Annotation 杩囦簬澶嶆潅锛岄偅杩樹笉鐒剁洿鎺ュ啓鍘熺敓浠g爜銆傛墍浠 PhpBoot 浣跨敤浜嗘洿绠鍗曠殑 Annotation 璇硶銆傚锛

/**
 * @route GET /books/{id}
 */
 public function getBook($id)...

1. 璇硶

@<name> [param0] [param1] [param2] ...

  1. name 鍙兘鏄繛缁殑瀛楁瘝銆佹暟瀛椼佹枩鏉''銆佷腑妯潬'-' 缁勬垚鐨勫瓧绗︿覆锛屽缓璁叏灏忓啓锛屽崟璇嶉棿鐢'-'鍒嗗壊锛屽@myapp\my-ann
  2. name鍜屽弬鏁帮紝鍙傛暟鍜屽弬鏁拌锛岀敤绌虹櫧绗︼紙涓涓垨澶氫釜杩炵画鐨勭┖鏍笺佸埗琛ㄧ锛夊垎鍓层
  3. 鍙傛暟涓鏋滃寘鍚┖鏍硷紝搴斿皢鍙傛暟鐢ㄥ弻寮曞彿""鍖呭洿锛屽寘鍥村唴鐨勫弻寮曞彿鐢╘杞箟锛屽 @my-ann "the param \"0\"" param1 绗竴涓弬鏁颁负the param "0"

鍒嗗壊鍙傛暟銆佽浆涔夌殑璇硶鍜宭inux 鍛戒护琛岀殑璇硶绫讳技

2. 宓屽

宓屽娉ㄩ噴锛岀敤{}鍖呭洿锛 姣斿@param int size {@v min:0|max:10}