OpenAPI(Swagger)ã§ããæãã«èªåãã¹ããããããã®ãã³ãã¼æ¡å¼µãèãã¦ã¿ãã
å®ç¾©ããã®ã¯ä¸è¨ã®äºã¤
- Path Item Object ã® x-create-operation
- Parameter Object ã® x-found-in
x-create-operationã¯ãã®ãªã½ã¼ã¹ãä½æããããã®æä½ã®operationIdãæå®ãã
x-found-inã¯ãã©ã¡ã¼ã¿ã¼ãåå¾ããããã®operationã¨ãã©ã¡ã¼ã¿ã¼ãã¬ã¹ãã³ã¹ã®ã©ãã«ãããã示ããªãã¸ã§ã¯ããããã¯åãªãã¸ã§ã¯ããå
±éå®ç¾©ãã#/x-found-ins/以ä¸ã¸ã®Reference Objectããã¦ãããã
ãã©ã¡ã¼ã¿ã¼ã®æå¨ã¯æå®ã¯Parameter Objectã¨åãããã«è¡ãã°ããã
APIã«ããçæã»åç
§ãä¸å¯è½ãªãã¤ã¯ãããã®å¤ãè¨å®ããªãã
ããã«ãã£ã¦ãä¾åãããªãã¬ã¼ã·ã§ã³ãæ示ãããã®ã§ã
(å帰åç
§ã«ãªã£ã¦ããªãéã)ããæãã«ãã¹ããã§ããã¯ãã
ç¶ãã¬ã¼ã ã¯ã¼ã¯ã®è²¬åã¨ã»ãã¥ãªãã£
å
æ¥ã®エントリã«å¯¾ãã¦ãã¾ãã¾ãªåå¿ãæ´ãã¾ããããããã¨ããããã¾ãã
ä»åã¯ãã®ä¸ããããã¤ããåãä¸ãã¦ããããã¨æãã¾ãã
ä»åã®ä»¶ã«é¢ãã¦ã¯ã¾ãåæã¨ãã¦Basicèªè¨¼ã®å®è£ ã§ããä»ã®èªè¨¼ã«ã¤ãã¦ã¯ãã£ãããããã«ãã¬ã¼ã ã¯ã¼ã¯ã§ã¯ä½ãè¦å¶ãè¦å®ããã¨ãã訳ã§ã¯ããã¾ãããã¾ããå¹³æãã¹ã¯ã¼ãä¿åã«ã¤ãã¦ã¯ç©æ¥µçã«æä¾ããªãã¨ããã ãã§ãããå¿ è¦ãªç¶æ³ã«å¿ãã¦å®è£ ãããã¨ããã¬ã¼ã ã¯ã¼ã¯ã§ç¦æ¢ããã¨ãããã¨ã§ãããã¾ããã
å¹³æãã¹ã¯ã¼ãä¿åããã¬ã¼ã ã¯ã¼ã¯ã§å®æã«æä¾ãã¦ãã¾ãã¨ããã®å±éºæ§ãç解ãã¦ããªãéçºè ãå©ç¨ç¨éãé©åã§ãªãå ´é¢ã§ä¹±ç¨ãã¦ãã¾ãå¯è½æ§ãé«ã¾ããããååãªæ³¨æåèµ·ãæä½éã¨ãã¦ã§ããã°æä¾ãé¿ãã(=éå£ãè¨ãã)ã¹ãã ã¨ãããã¨ã§ãã
PRã§ãåã¯ä¸è¨ã®ããã«è¨åãã¦ãã¾ãã
æ¡å¼µã»å¤æ´ã容æãªããã«DIãAOPãå°å ¥ãã¦ããã®ã§ã¨ãã¸ã±ã¼ã¹ã«ã¯å¯¾å¿ããªãã¨ããã®ã§ããã°ã
ãããããã¬ã¼ã³ããã¹ãã§ãã¹ã¯ã¼ããã½ã¼ã¹ã³ã¼ãã«è¨è¿°ããªããã°ãããªããããªå±éºãªè¦ä»¶ã¯ã¨ãã¸ã±ã¼ã¹ã¨ãã¦æ±ã£ã¦å®è£ 対象ããå¤ãã¹ãã ã¨åã¯æãã¾ãã
ãã®ä»ãkoriymãããæ®´ãæ®´ããªãã¨ããã³ã¡ã³ããããã¾ãããããã£ã1度ã®æè¦ã®å¯¾ç«ã§æ´åã«è¨´ããã¨ãã©ããªä¸ç´æ«ã§ããã
ã¡ãªã¿ã«ä»å¤ã¯ãã¼ã¹ããã¼ããä»è¾¼ãã§ãã¾ãã
ãã¬ã¼ã ã¯ã¼ã¯ã®è²¬åã¨ã»ãã¥ãªãã£
ãä¹
ãã¶ãã§ãã å¤ä¸ã«ã¢ãç
®è¾¼ã¿ä½ããªããæ¸ãã¦ã¾ãã
ãã¦ãä»åã¯ãã¬ã¼ã ã¯ã¼ã¯ã®è²¬åã¨ã»ãã¥ãªãã£ã«ã¤ãã¦æãã¨ããããã£ã¦ä¹
ãã¶ãã«ã¨ã³ããªãæ¸ããã¨ã«ãã¾ããã
èæ¯
ã¾ããèæ¯ã¨ãã¦BEAR.Sundayã®ä¸é¨ã§ããBEAR.Packageã«ãµã³ãã«ã¨ãã¦Basicèªè¨¼ã®å®è£ ã追å ããPullRequest#90ã§ã®ããåããããã¾ãããã®PRã¯zukimochiããã作ったものã«åãä¿®æ£ãå ãã¦åºããç©ã§ãããã®ä¸ã§ã¯ãBasicèªè¨¼ç¨ã®ãã¹ã¯ã¼ããããã·ã¥ã¨ãã¦æ±ãããã«å®è£ ããã¦ãã¾ãã
å¤ãã®äººãæãèªã¿ãã¦ããã®ã¯èæ¯èª¬æãé·ãããããã ã¨æã£ãã®ã§åé¤ãã¾ããã詳ããç¥ãããæ¹ã¯PRãã覧ãã ããã
æ¬é¡
ããããæ¬é¡ã§ãã PRã®æå¾ã«koriymãããçºè¨ãã¦ãã次ã®è¨èã¯ãã¬ã¼ã ã¯ã¼ã¯éçºã«æ¼ãã¦ã¨ã¦ãéè¦ã§ãã
ããé¢å¿ã®ããåé¡ã«éä¸ããããã«ãç¹ã«å°éã¨ãã¦ããªãåé¡ã«æ³¨åããããªãããã«ããããã«å½¹ç«ã¦ã¦ããã®ã§ãã
è¨ãæããã°ããä½è¨ãªæ©è½ä½ã£ã¦ãæãã£ãããããããã¬ã¼ã ã¯ã¼ã¯ä½ãããï¼ãã¨ãã£ãã¨ããã§ããããããã®èãããã¨ã«éçºãããã¨ã«ãã£ã¦ãã¬ã¼ã ã¯ã¼ã¯ã¯èãåãè½ãã¦ãéª¨æ ¼ã ãããã¤æ çµã¿ã¨ãã¦ããæ´ç·´ããã¦ããã¾ãã
ããã§éè¦ã«ãªã£ã¦ããã®ããåãè½ãã¹ããã®ã¨åãè½ãã¦ã¯ãªããªããã®ã®ç·å¼ãã§ããå ã®PRã§ã®åçã¯ãçãã¹ã¯ã¼ãã®ã»ããªãã£ãªã¹ã¯ãããã®ç·ã®å ãå¤ããããã¯å å´ã®å ´åã©ã対å¦ããã®ãã®è°è«ã«ãªãã¾ããã¡ãªã¿ã«ãæ¬ã¨ã³ããªã®ã¿ã¤ãã«ããã¬ã¼ã ã¯ã¼ã¯ã®è²¬åã¨ã»ãã¥ãªãã£ãã®è²¬åã¨ã¯å¢çç·ã®å å´ã®ãã¨ã§ãã
ã§ã¯ããã®å®è£ ããã¬ã¼ã ã¯ã¼ã¯ã®å®è£ ã¨ãã¦åãè¾¼ã¾ããã¨ããåæã§è©±ãé²ãã¾ãããã
ããã§ãçãã¹ã¯ã¼ãä¿åæ©è½ãåãè½ããã«ãªãªã¼ã¹ããå ´åã«æ³å®ãããã»ãã¥ãªãã£ãªã¹ã¯ãèãã¦ã¿ãã¨ããããªã·ããªãªãæµ®ãã³ã¾ãã
- éçºè ãçãã¹ã¯ã¼ããè¨å®ãã¡ã¤ã«ã«æ¸ãå½¢ã§ç®¡çç»é¢ã®ã¢ã¯ã»ã¹å¶å¾¡ãè¡ãã¢ããªã±ã¼ã·ã§ã³ãä½æ
- ã¢ããªã±ã¼ã·ã§ã³å©ç¨è AãSNSã§ãå©ç¨ãã¦ãããã¹ã¯ã¼ããè¨å®ãã¡ã¤ã«ã«æ¸ãã¤ã³ã¹ãã¼ã«
- ã¢ããªã±ã¼ã·ã§ã³ã®ãã°(ãã£ã¬ã¯ããªãã©ãã¼ãµã«èå¼±æ§)ãå©ç¨ãæ»æè ããã¹ã¯ã¼ãè¨å®ãã¡ã¤ã«ãåå¾
- æ»æè ãã¢ããªã±ã¼ã·ã§ã³å©ç¨è Aã®SNSã¢ã«ã¦ã³ããä¹ã£åã
ããå
·ä½çã«ãã¾ãã
ããã¯ãPRã§æããåé¡ç¹ã®å
·ä½ä¾ã§ããã
ã§ã¯ããã®ã»ãã¥ãªãã£ãªã¹ã¯ã«å¯¾ãã責åã¯ãã¬ã¼ã ã¯ã¼ã¯ã«ããã®ã§ãããã? ããã¨ãããã¬ã¼ã ã¯ã¼ã¯ã®æ¬è³ªã§ã¯ãªãã¨åãæ¨ã¦ãã¹ãã§ãããã?
åã¯ãã¬ã¼ã ã¯ã¼ã¯ã®è²¬åã§ããã¨èãã¾ãã æä¾ããæ©è½ãã»ããªãã£ãªã¹ã¯ãæ±ãã¦ããã®ã§ããã°å½ç¶ã§ãããã¬ã¼ã ã¯ã¼ã¯ã«ä½åãªè¤éããæã¡è¾¼ã¿ãããªãã®ã¯åãã¾ãããä¸è¬ã«ã¯ããããã¹ãã§ãããã»ãã¥ãªãã£ãªã¹ã¯ã絡ãå ´åã¯ãªã¹ã¯åé¿ããã¬ã¼ã ã¯ã¼ã¯ã®è²¬åã§ãã
ãªãã°ã©ãããã°ããã®ããé¸æè¢ã¯3ã¤ã»ã©ããã¾ãã
ï¼ã¤ç®ã¯ãåé¡ã®æ©è½èªä½ãåãæ¨ã¦ããã¨ã§ãã ãããã¬ã¼ã ã¯ã¼ã¯ã®æ¬è³ªãæãªããªãã®ãªãåãæ¨ã¦ã¦ãã¾ãã°ç°¡åã§ãããã¬ã¼ã ã¯ã¼ã¯ãååãªæ¡å¼µæ§ãæã£ã¦ãããªãã°ã第ä¸è ã«ããå®è£ ã«æå¾ ãããã¨ãã§ãã¾ãã
2ã¤ç®ã¯ãã»ãã¥ãªãã£ãªã¹ã¯ãæ±ãã¦ãããã¨ããã¬ã¼ã ã¯ã¼ã¯ã®å©ç¨è (=ã¢ããªã±ã¼ã·ã§ã³éçºè )ã«å¯¾ãã¦å¨ç¥å¾¹åºãããã¨ã§ãã ããã¥ã¢ã«ãã½ã¼ã¹ã³ã¼ãä¸ã®ã³ã¡ã³ãã«ãããå®ã注æäºé ã表示ãã¾ããå ã®ã·ããªãªã§ã¯éçºè ãåºãä¸è¬ã«ä½¿ãããã¢ããªã±ã¼ã·ã§ã³ãçãã¹ã¯ã¼ããå©ç¨ããå½¢ã§å®è£ ããªããã°ããªã¹ã¯ã¯åé¿ã§ããããã§ããæ¶æ¥µçãªå¯¾çã§ãããããã¥ã¢ã«ããã¡ãã¨èªã¾ãªãéçºè ãæ³å®ããã¨ã¾ã ãªã¹ã¯ã¯æ®ãã¾ããã責åãæããã¦ããã¨è¨ããã§ãããã
3ã¤ç®ã¯ããªã¹ã¯æé¤ããå®è£ ãæä¾ãããã¨ã§ããä»åã§è¨ãã°ãçãã¹ã¯ã¼ãä¿åãæä¾ãããé©åãªããã·ã¥åãªã©ãç¨ãããã¹ã¯ã¼ãä¿åã®ã¿ãæä¾ãã¾ãã ãã¡ãããçãã¹ã¯ã¼ãä¿åæ©è½ãèªåã§éçºãã¦å©ç¨ãã¦ãã¾ãéçºè ã¨ãããªã¹ã¯ã¯ã¾ã ããããã§ããããããè¨ãåºããããããã«ããããªãã§ãããæ°´ãä½ãæ¹ã«æµããããã«ãéçºè ã楽ã«å®è£ ã§ããæ¹ã«æµããã®ã§ãã£ã¨ããã·ã¥åããããã¹ã¯ã¼ãä¿åãå©ç¨ãã¦ãããã§ãããã(ãããPRã§ã®åã®ä¸»å¼µã§ã)
æçµçã«ã©ããé¸æãããã¯ãªã¼ãã³ããã¿ã¼ããããã¯ããªã¼ãã¼ã®éé ã«ãããã¨ã«ãªãã¾ãããä½ã対çããªãã¨ããã®ã¯ããå¾ã¾ããããªã¼ãã³ã½ã¼ã¹ã§ã¿ãã§éçºãã¦ãã¦ãããã®å«çç責任ããéãããã¨ã¯ã§ãã¾ããã
ã¾ãã3ã¤ç®ã®ç©æ¥µçãªè§£æ±ºæ¹æ³ã容æã«ã¨ããã¨ãã§ããã®ã§ããã°ã2ã¤ç®ãæ¡ç¨ããã®ã§ã¯ãªã3ã¤ç®ã§å¯¾çãè¡ãã¹ãã§ãããã責任ã®ç¯å²å
ã§ã¯ãã¹ãã¨ãã©ã¼ãããªãã¹ãã§ãã
çµè«
ãã¬ã¼ã ã¯ã¼ã¯ãå«ãããããã¯ãéçºã«æ¼ãã¦ã¯ã»ãã¥ãªãã£ãªã¹ã¯ã常ã«èããé©åãªå¯¾çãè¬ããã¹ãã§ããã
ã»ãã¥ãªãã£ã®å°é家ã®æ¹ããã®ãæè¦ãé ãããå¬ããã§ããã
ãã¦ãã¢ãç
®ãããæãã«åºæ¥ä¸ãã£ãã®ã§å³è¦ãã¦ãã¾ãã ããé±æ«ãã
ä»ããJSONãã¼ã¹ã®Hypermediaãã©ã¼ãããä»æ§ã¾ã¨ã
RESTful Web APIs: Services for a Changing World (English Edition)ãããã ããªãã ããã¦ãJSONãã¼ã¹ã®Hypermediaãã©ã¼ãããã«èå³ãåºãã®ã§èª¿ã¹ã¦ã¿ã¾ããã
ããã§ç´¹ä»ãããã©ã¼ãããã¯2013å¹´10æ6æ¥ç¾å¨ã©ããçå®æ®µéã§ãã
ãªã¹ãåããã«å½ããã°ã°ã£ã¦ãããã¨ããªãã£ãã®ã§ãIANAã«ç»é²ããã¦ããmedia-typeã®ãã¡"+json"ãæ¥å°¾è¾ã«æã£ã¦ãããã®ããããã£ã½ãã¢ããé¸ã³ã¾ããã
Collection+JSON
ãã®åã®éããã³ã¬ã¯ã·ã§ã³(ãå«ã)ãªã½ã¼ã¹ã®ããã®ä»æ§ã§ãã
ãã®ä»æ§ã§ã¯ã³ã¬ã¯ã·ã§ã³ã®åç
§ã ãã§ã¯ãªããã³ã¬ã¯ã·ã§ã³ã«å¯¾ãã追å ã»æ´æ°ã»åé¤æä½ã«è¨åãã¦ãã¾ãã
Collection.next+JSON
ä¸è¨Collection+JSONã®æ¡å¼µããããè¤éãªå®ç¾©ãã§ããããã«ãã¦ãã¾ãã
追å ããã¦ãã主ãªæ©è½ã¯ä¸è¨ã«ãªãã¾ãã
- ãã©ã¼ã ã¸ã®é¸æè¢ã®æ示
- HTTP 202 Acceptedã¨ã¨ãã«è¿ãããã¬ã¹ãã³ã¹ã§å©ç¨ããstatus表ç¾
- ãã¤ãã¼ãªã³ã¯ããã³ãã¬ã¼ãå®ç¾©ã«ãããå(type)æå®
Siren: a hypermedia specification for representing entities
ãµãã¿ã¤ãã«ã®ç¤ºãéããã¨ã³ãã£ãã£(ãªã½ã¼ã¹)ã表ç¾ããããã®ä»æ§ã§ãã
Collection+JSONç³»ã¨ç°ãªããã¨ã³ãã£ãã£ã®è¡¨ç¾æ¹æ³ã«ã¤ãã¦ãè¨åãã¦ãã¾ããã¾ããã©ã¼ã 表ç¾ãå
å®ãã¦ãããæè»ã«è¿½å ã»æ´æ°ãè¡ãã¾ãã
æ ªå¼ä¼ç¤¾VOYAGE GROUPãéè·ããã¦ã§ããã¦ã æ ªå¼ä¼ç¤¾ãè¨ç«ãã¾ããã
ãä¹ ãã¶ãã§ããã¢ããã³ãã«ã¬ã³ãã¼ä»¥æ¥ã®æ稿ã¨ãªãã¾ããã
ãã¦ããã®åº¦ã3æ31æ¥ä»ã§VOYAGE GROUPãéè·ãã¾ããã
PHPã«ã³ãã¡ã¬ã³ã¹2011ã®ç¿æ¥ã®2011å¹´9æ12æ¥ã«æ ªå¼ä¼ç¤¾ECããã«å ¥ç¤¾ããç¿10æã«æ ªå¼ä¼ç¤¾VOYAGE GROUPã«ç¤¾åå¤æ´ããã®å¾MBOãè¡ãIPOãç®æãã¨å®£è¨ãããã¨ããæ¿åã®ææã«å é¨ã§é¢ãããã¨ãã§ãã¾ããã
ç§ã®å ¥ç¤¾ããé ã¯VOYAGE GROUPå ã®ã¨ã³ã¸ãã¢é£ãå¼·åãããææã§ããããå ã ããåªç§ãªã¨ã³ã¸ãã¢ã«å ãã¦æ§ã ãªåéããã®ä¸éçµã¨ä¸ç·ã«ä»äºãããããé¨ç½²ã®éãæ¹ã¨ã¯ç¤¾å åå¼·ä¼ãªã©ãéãã¦åºæ¿ãåãããã¨ãã§ãã¾ããã ã¾ããããã¾ã§çµé¨ãã¦ããªãã£ããå°ä»»ã®ã¤ã³ãã©ãã¼ã ãå± ãç°å¢ã§åããã¨ãéãã¦ãå¤ãã®ãã¨ãå¦ã¶ãã¨ãã§ãã¾ããã
VOYAGE GROUPã¨ããä¼ç¤¾ã¯ãã³ã¼ãâã¬ã¼ãã«ã«ãã£ã¼ã®æ¨é²ã«å°ä»»æ å½è ãè¨ãã¦ãã¦ãåæã«1度ã®ç·ä¼ãVOYAGE CUPã¨ããéåä¼ãã¯ãªã¹ãã¹ãªã©ã®å¹´ä¸è¡äºãªã©ã®åºæ¿ã¨æ¥½ãã¿ã«æºã¡ãã¨ã¦ãè¯ãè·å ´ã§ããã
ã¾ããç¦å©åçã¨ãã¦ååæãã¨ã«å å ¥ã§ãããµã¼ã¯ã«æ´»åãéãã¦1å¹´åãããã«ããªã³ã°ãå§ãã¾ããã æ¬å½ã«æ¥½ããæ´»åã§ããã®æ´»åãéãã¦CTOã®å°è³ããã¨ã親ãããªããã¨ãã§ãã¾ããã ä»å¾ããã«ããªã³ã°ãµã¼ã¯ã«ã®æ´»åã«ãä¸ç·ãããã¨æã£ã¦ãã¾ãã
èªåã®ä¸ã®äºå®ã§ã¯ããã£ã¨ãã£ã¨ãVOYAGE GROUPã®ä¸å¡ã¨ãã¦åãç¶ããã¤ããã§ãããæ¬å¿ããããæã£ã¦ãã¾ããã ãããããåãç²æã®ããä¼ç¤¾ã§ããã
ããã©ãæ¼¢ã«ã¯å¤¢ãããã¾ãã
åã®å¤¢ã¯ããã¤ããä¿¡é ¼ã§ãã人ã¨ã¨ãã«ä¼ç¤¾ãèããæ¥æ¬ã«ããã¦ä¸çã«èªãããµã¼ãã¹ãåµãããã¨ãããã®ã§ãã åã¯ãããã«ãªããæ§æ ¼ã§ã¯ãªãã®ã§ã社é·ã«ã¯ãªãããããªãã®ã§ãã¼ããã¼ãå¿ è¦ãªã®ã§ãã
ããã¦ãã¤ãã«ãä¿¡é ¼ã§ãããã¼ããã¼ã«ãããåããã¨ãã§ãã2013å¹´4æ1æ¥ã«ウェブニウム株式会社ãè¨ç«ãããã¾ããã
ããããã¯ãä¸å¾æ¥å¡ã¨ããç«å ´ãåæ¥ããåç· å½¹CTOã¨ãã¦ç²¾é²ãã¦ããã¾ãã æ¹ãã¦ããããããé¡ããã¾ãã
PHPerã®MVCã®ä¸ä½ã©ããééã£ã¦ããã®ã
ã¡ãªã¼ã¯ãªã¹ãã¹ï¼ PHP Advent Calendarããããã24æ¥ç®ã«çªå
¥ã§ãã
æ¨æ¥ã¯xhprofã«ã¤ãã¦ã§ããããåãããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°ã®éã«ä½¿ã£ã¦ãã¾ããæ軽ã«å©ç¨ã§ããã®ã§ãå§ãã§ãã
ãã¦ããã®ã¨ã³ããªã¼ã§ã¯è¡¨é¡ã®éãMVCã«ã¤ãã¦æ¸ããã¦ããã ãã¾ããããã¯ãPHPã«ã³ãã¡ã¬ã³ã¹2012&WordCamp Tokyo2012ååLT大ä¼ã§çºè¡¨ãããやはりお前らのMVCは間違っているãã§ç
½ãã ãã ã£ããã®åé¡ããã¡ãã¨è§£èª¬ãããã®ã§ãã
ãã®çºè¡¨è³æãå
¬éããã¨PHPã®æ ãè¶
ãã¦åºãé²è¦§ããã ã*1ãã¾ãå¤ãã®æ¹ããçªã£è¾¼ã¿ãæ´ãã¾ããããLTã ãããã¨è¨ã£ã¦éãã¦ããåçããã¦ãæ°æã¡æ°ãã«æ°å¹´ãè¿ãããã¨æãã¾ãã
MVCã¨ã¯ãªããªã®ã
ééããææããåã«MVCãããããã©ãããã¢ã¼ããã¯ãã£ã§ããã®ãã確èªããªããã°ããã¾ããã
MVCã¯1970年代ã«ããã¢ã«ãç 究æ(Xerox Parc)ã§çºæããã1980年代ã«Smalltalk-80ã®ããã¥ã¡ã³ã*2ã«ç»å ´ãã¾ãããã®MVCã®ã³ã³ã»ããã¯GUIã¢ããªã±ã¼ã·ã§ã³ã«ããã¦ãªãã¸ã§ã¯ãã3ã¤ã«åé¡ãã¾ããã
- Model
- ãã¡ã¤ã³é åã®ãã¼ã¿ã¨æ¯ãèã
- View
- ã¦ã¼ã¶ã¼ã«å¯¾ããè¦è¦è¡¨ç¾
- Controller
- ã¦ã¼ã¶ã¼ã®æä½ãåãåãModelãViewã«å½ä»¤ãéã
ã¾ãããããå®ç¾ããããä¸å³ã«ç¤ºãããªãã¶ã¼ãã¼ãã¿ã¼ã³ã«ããé£æºãç¨ãã¾ããã
ãããããMVCã®åç¹ã§ãã
@koichikããããã®ææã«åºã¥ãä¸å³ãå¤æ´ãã¾ãããå¾ã«ä¸å³ã®ãããªé£æºãåºã¦ãã¾ãããåç¹ã§ç¤ºãã¹ãã¯ä¸å³ã§ãããè¨æ£ãã¦ãè©«ã³ãã¾ãã
Webã¸ã®å¯¾å¿
Webã¸ã®MVCã®å°å
¥ã¯JAVAçéã§è¡ããã¾ããããã®æãHTTPãã¹ãã¼ãã¬ã¹ã§ãããã¨ã«å¯¾å¿ãã¦MVCã«å¤æ´ãå ãMVC2ã¨ãã¾ãã*3 *4ãããªãã¡ãMVéãVCéã®ãªãã¶ã¼ãã¼ãã¿ã¼ã³ã«ããéç¥ãæé¤ãä¸å³ã®ãããªæ§æã«ãã¾ããã
ãã®ããã«MVC2ã§ãããããã®å½¹å²åæ
ãã¯ã£ãããã¦ãããã¾ããã¼ã¿ã®æµããåä¸ã§ãã
ã§ã¯Strutsã®å®è£
ãè¦ã¦ã¿ã¾ããããStrutsã®MVCå®è£
ã¯ä¸å³ã§ç¤ºãããã®ã¨ãªãã¾ããViewãJSP(ãã³ãã¬ã¼ã)ã§Actionã¨ActionForm BeanãModelé åã¨ãã¬ã¼ã ã¯ã¼ã¯ã¨ã®éã«ç«ã¤ã¢ããã¿ã¼ãã¿ã¼ã³ãæ¡ç¨ãã¦ãã¾ããViewãJSPã«ãªã£ãèæ¯ã«ã¯ãã¶ã¤ãã¼ã®ç¯å²ãåé¢ããæå³ããã£ãããã§ãã*5
PHPã§ãMVC2å®è£ ããªãããMojaviã¨ãã¦å ¬éããã¾ãããStrutsããã®å¾ã«ç»å ´ããå¤ãã®WebApplicationFramework(WAF)ã§Viewããã³ãã¬ã¼ãã®ã¿ã§æ§æã¦ããã®ã«å¯¾ãã¦ãMojaviã§ã¯Viewããã³ãã¬ã¼ãã¨Viewã¯ã©ã¹ã®2ã¤ã§æ§æãã¦ããã®ãç¹å¾´ã§ããããã«ãããè¤éãªãã¬ã¼ã³ãã¼ã·ã§ã³ãã¸ãã¯ããã³ãã¬ã¼ãããæé¤ããªãããã³ã³ããã¼ã©ã®è¥å¤§åãé¿ãã¦ãã¾ãã(è£ãè¿ãã°ãViewããã³ãã¬ã¼ãã®ã¿ã§æ§æããã¨ãã¬ã¼ã³ãã¼ã·ã§ã³ãã¸ãã¯ãè¡ãå ´ã失ãã¾ãã)
Ruby on Railsã®ç»å ´
Ruby on RailsãWAFã«ä¸ããã¤ã³ãã¯ãã¯çµ¶å¤§ã§ããã ãã«ã¹ã¿ãã¯ã§ãããèªåã³ã¼ãçææ©è½ããã¹ãæ©è½ããã¦ActiveRecordãªã©ããã®ææ³ã¯å¾ç¶ã®å¤ãã®WAFã«å½±é¿ãä¸ãã¦ãã¾ãã
Railsã«ããã¦Modelãçæããã«ã¯æ¬¡ã®ã³ãã³ãããããã ãã§ããã
rails generate model profile
ãã£ãããã ãã§ãããã£ã¼ã«ã¯ã©ã¹ã®ã²ãªå½¢ãåºæ¥ä¸ããã¾ããããã¦åºæ¥ä¸ãã£ãã²ãªå½¢ã¯ActiveRecordãç¶æ¿ãã¦ãã¾ãããããMVCåå¿è ã«èª¤è§£ãä¸ãããã¨ã«ãªãã¾ããã
RoRã®ã³ãã³ãã§çæãããã¢ãã«ã¯ãã¡ã¤ã³ã¢ãã«ã§è¨ãã¨ããã®ã¨ã³ãã£ãã£ã«å½ãããã®ã§ããããã¯MVCã®ã¢ãã«ã®é¨åéåã«ããã¾ããããããã"ã¢ãã«çæã³ãã³ã"ã§çæããããã®ã ããã¢ãã«ã§ããã¨äººã ã«èª¤è§£ãä¸ããã®ã«ååã§ããã*6
ãã®çµæãæ¬æ¥ã¢ãã«ã«å®è£ ãããã¹ããã¸ãã¹ãã¸ãã¯ãè¡ãå ´ã失ãã³ã³ããã¼ã©ã¸éã¾ã£ã¦ãã¾ãã¾ããããããã¦æãã¹ããã¡ããã³ã³ããã¼ã©ãéç£ãããããã«ãªãã¾ãã
ãã®æ³¢ã¯PHPã«ãCakePHPã¨ãã¦è¨ªãã¾ããCakePHPã¯ã¾ãããRoRã®ã¯ãã¼ã³ã§ãããèªåã³ã¼ãçæã«ããActiveRecordãªã¢ãã«ãçæãã¾ããããããããã®ã¯ã©ã¹ã®åºåºã¯ã©ã¹ã¯AppModelã¨ããååã§ãããçµæã¨ãã¦å¤ãã®PHPerãMVCã誤èªèãããã¨ã«ãªãã¾ããã
PHPerã®èªèãã¦ããMVC
ãã¦ããã®ããã«ãã¦å¤ãã®PHPerãèªèããMVCãèªçãã¾ããããã®ç¹å¾´ãä¸åº¦æ´çãã¦ã¿ã¾ãããã*7
- Model
- èªåçæãããã¢ã¯ãã£ãã¬ã³ã¼ãã®ã¢ãã«
- View
- ãã³ãã¬ã¼ããã¡ã¤ã«ããã¸ãã¯ã¯æé¤ãã¢ãã«ã¸ã®ã¢ã¯ã»ã¹ã¯å³ç¦ã
- Controller
- Model,View以å¤ã®ãã¹ã¦ãã³ã³ããã¼ã«
ã¾ãMVCéã®é¢é£ãä¸å³ã«ç¤ºãã¾ããã
ãã®ã¢ã¼ããã¯ãã£ã§ã¯å¿
ç¶çã«ã³ã³ããã¼ã©ã¯è¥å¤§åãã¾ãã
ä½ãééã£ã¦ããã®ã
ããã¾ã§ã®èª¬æã§PHPerã®èªèããMVCã¨Smalltalk MVCã®éããç解ããã ãããã¨æãã¾ãã
件ã®LTçºè¡¨ã«ããã¦ç§ããééã£ã¦ãããã¨æè¨ããã®ã¯ããã®éãã«ããåé ã§ç´¹ä»ããMVCã®ã³ã³ã»ããããå¤ãã¦ãã¾ã£ã¦ããããã«ã»ããªãã¾ãããã³ã³ã»ããããºã¬ã¦ããã®ã«ãããMVCã¨å¼ã³ç¶ãããã¨ã¯åé¡ç¡æ¥ã¨è¨ãããããã¾ããã
ããããMVCããå¤ãããã¨ãã®ãã®ã¯æªã§ã¯ããã¾ãããMVCã¨ã¦å®ç§ãªã¢ã¼ããã¯ãã£ã§ã¯ãªãã§ããããããããGUIã¢ããªã±ã¼ã·ã§ã³ç¨ã®ã¢ã¼ããã¯ãã£ãªã®ã§Webã¢ããªã±ã¼ã·ã§ã³ã«ã¯é©ããªã(ãããã¯ãªã¼ãã¼ã¹ããã¯ãª)é¨åãããã¾ãã
ããã¦ãããMVCã«ç¢ºåºããæå¿ããã£ã¦ã³ã³ã»ããããå¤ãããããªæãå ãã¦ãã®ã§ããã°ããã®ã¢ã¼ããã¯ãã£ã«æ°ããååãã¤ããã®ãè¯ããã¨æãã¾ãã
çµè«
PHPerã®èªèããMVCãã©ã®ããã«åºæ¥ä¸ãã£ãã®ããæ¯ãè¿ãã¾ãããMVCã®ã³ã³ã»ããããã®ãããçããèæ¯ã«ã¯ä½ããã®åé¡ã解決ããææããã£ãã®ã ã¨æãã¾ãããããããã®ããã¯æ¬¡ç¬¬ã«å¨ãã«å½±é¿ãä¸ãçµæã¨ãã¦å¤ãã®äººãå
¨ãå¥ç©ãMVCã¨ãã¦èªèããã«è³ãã¾ãããæã«ã¯ç«ã¡æ¢ã¾ããæ¯ãè¿ããã¨ã大åãªãã ã¨çæããããã¾ãã
2012å¹´ããã¨å°ãã§ããç§ãã¡ãä»å¹´ãæ¯ãè¿ã£ã¦å°ããªééãã®ãã¡ã«æ¹ãã¦ããã¾ãããã
PHP Advent Calendarãææ¥ã¯ãããã25æ¥ç®ãã¸ã§ãã¬ã¼ã¿ãå®è£ ãããPHP5.5ã«åãã¦foreachã«ã¤ãã¦ã®ã話ã§ãã
*1:ã¾ããã®3ä¸viewsè¶ã!
*2:ãããä¸ã«ã¯åå ¸ã¯è¦ã¤ããã¾ããã§ããã®ã§å¾ç¶ããã¥ã¡ã³ãã示ãã¾ã "Applications Programming in Smalltalk-80(TM):How to use Model-View-Controller (MVC)" by Steve Burbeck, Ph.D. http://st-www.cs.illinois.edu/users/smarch/st-docs/mvc.html
*3:MVC2ã¨ããç¨èªã¯JSFã®MVC対å¿Type2ãæããã®ãããããããçµæã§ããã¨ããªãã¨ãï¼è¦åºå ¸
*4:ãã¡ãã®"Model2" architectureãå ã®ããã§ã http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-eedocs-419425.html#7036-design_ent_app-2.0-oth-JPR
*5:åè: http://struts.apache.org/1.x/index.html
*6:åè: Life is beautiful: Ruby on Railsの「えせMVC」の弊害
*7:ããã¦ãä¸çªãã¡ãªä¾ãåºãã¾ã
VOYAGE GROUPã§æ°åã¨ã³ã¸ãã¢ãçæããè¦å®ã£ãã話 #vgadvent2012
â»ãã®è¨äºã¯VOYAGE GROUP エンジニアブログ : Advent Calendar 2012ã®13æ¥ç®ã®è¨äºã¨ãã¦æ¸ããã¦ãã¾ãã
ãç¡æ²æ±°ãã¦ããã¾ãããããã¯ã¯ããã¾ãã¦ã ãã1å¹´å¼·ãVOYAGE GROUPã§PHPerã®ãã¬ã³ãã社å
ã«ä¼ããä»äºããã¦ãã¾ããã¤ãã§ã«ã·ã¹ãã ãä½ã£ã¦ãã¾ãã
ãã¦ãVOYAGE GROUPã¨ã³ã¸ãã¢ããã° Advent Calendar 2012ã13æ¥ç®ããã£ã¦ã¾ããã¾ãããããããå¾åæ¦ã§ãããã®ã¨ã³ããªã§ã¯ç©ºæ°ãèªã¾ãã«çé¢ç®ãªè©±ãé©å½ã«æ¸ãããã¨æãã¾ãã
2012å¹´4æã«å¼ç¤¾VOYAGE GROUPã«ã¯å¤ãã®æ°åãå
¥ã£ã¦ãã¾ãããå
¥ç¤¾ããã¨å½¼ãã¯1ãæã®åºç¤ç ä¿®ãåãããã¨ã«ãªãã¾ããã¨ã³ã¸ãã¢ã¨ãã¦å
¥ç¤¾ããæ°åãã¡ã¯ããã«æè¡ç ä¿®ãåãããã®å¾ããããåé¨ç½²ã«é
å±ã¨ãªãã¾ããé
å±ãããå¾ãOJTæ
å½ãã¤ãããã¦å®å°ã§ã®ç ä¿®ã¨ãªãã¾ãã
ãããªå½¼ãã¨ç ä¿®ã®æå®ã§ãOJTæ
å½ã§ããªãç§ããã®1å¹´ã©ã®ããã«é¢ãã£ã¦æ¥ãããç´¹ä»ãããã¨æãã¾ãã
åãé¨ç½²ã®æ°åã¨ã®é¢ãã
é¨ç½²å ã®æ°åã¨ã¯èªç¶ã¨é¢ãããå¤ããªãã¾ããOJTæ å½ã§ãããã¯é¢ä¿ãªãåºæ¥ãéãã®æå°ãè¡ãã¾ããã
社å ã§ã³ã¼ãã¬ãã¥ã¼ãè¡ã風潮ãæ ¹ä»ãã¦å± ãããããæ°åã®æå°ã®æ©ä¼ã¨ãã¦å©ç¨ãããã¨ãã§ãã¾ãããé常ã®ã¬ãã¥ã¼ã§ã¯åé¡ç¹ãææããã ãã§ãããæ°åç¸æã®å ´åã«ã¯è©³ãã説æãããããéã«ããã¨ãã³ãã ãä¸ããã¨ãããã¨ããã¾ããã
ã¾ããä¸äººã§ã¯è§£æ±ºãé£ãããã ã¨å¤æããå ´åã«ã¯ãã¢ãããè¡ããã¨ãä½åº¦ãããã¾ããããã¢ããã§ã¯ä¸»ã«æ°åã®ãã«ãã©ã¤ãã¼ãä»»ãã¦ãã¾ãããèªç±ã«æ¸ããã¦è©°ã¾ã£ã¦ããã¨ããæããã«ééã£ã¦ããã¨ããã³ããä¸ããå½¢ã§ããèããåãä»ããã«ã¯ãã©ã¤ãã¼ã®æ¹ãåãã¦ãã¾ãããã
ã¨ããã§ãåãé¨ç½²ã«é
å±ãããæ°åã«ã¤ãã¦å¼ç¤¾CTOã®å°è³ã¨è©±ãããæ©ä¼ãããã¾ããããã«ããªã³ã°ãµã¼ã¯ã«ã®å¾ã ã£ããã¨æãã¾ãã
ãã®æã®è©±ã®ä¸ã§2ã¤ã®è¨èãå°è±¡ã«æ®ã£ã¦ãã¾ãã
1ã¤ç®ã¯ã失æãããæ¹ãè¯ããã¨ãã趣æ¨ã®è¨èã§ãã失æãããã¨ã«ãã£ã¦ã¯ããã¦å¦ã¹ããã¨ãããã®ã§(åãè¿ããç¯å²ã§)失æãçµé¨ãããã¹ãã ã¨ãããã¨ã§ããã失æããã¨ããã£ã¦ããã®ãããã¦ä½ãè¨ããã«è¦å®ãã®ã¯ã¨ã¦ãå´åã使ããã¨ã§ããæ¬å½ã«è¦å´ãã¾ããã
2ã¤ç®ã¯ãå±ã人ãå¿ è¦ã ãã¨ããè¨èã§ãããã®è©±ãæã£ã¦ãããæ°åã®Rããã«å¯¾ãã¦ããã¦å³ããå½ããããã«ãã¾ããããã°ããããã¨è ããããæ§ã«ãªãã¾ãããããã®åæ°æã¡ãå¼ãç· ãã¦ä»äºããã¦ããããã®ã§ã¯ãªããã¨æãã¾ãã
ãããªæå°ã®ãããããå½¼èªèº«ã®åªåã®ãã¾ãã®ããRãããæè¿ä»é¨ç½²ã®ã¨ã³ã¸ãã¢ã«è¤ãããã¦ããã¨ã®åãè³ã«ãã¾ãããã¨ã¦ãããããã£ãã§ãã
ä»é¨ç½²ã®æ°åã¨ã®é¢ãã
å½¼ãã¨ã¯ç¤¾å
åå¼·ä¼ã§ã®ããããã主ã«ãªãã¾ãã社å
åå¼·ä¼ã§ä½åº¦ãç»å£ããæã«ã¯æ欲çã«è©±ãèãã¦ããã¾ããã
åå¼·ä¼å¾ã«ç¤¾å
ãã¼ã®AJITOã§è©±ãã¨ãã¨ãããã¾ãããããå°ãé¢ããããããã£ããªã¨æããªãããªãã§ãã
ã¾ã¨ã
ã¾ã¨ããã ãã®ä¸èº«ããªãã®ã§ãããä½ã¨ãªãVOYAGE GROUPã®é°å²æ°ãä¼ãã£ã¦ããã°ãããªã¨æãã¾ãã
ææ¥ã®æ å½ã¯@kuromatuããã§ãã