ãã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾åãããã«æ¸ããã
ï¼2021-01-13 追è¨ï¼ ããã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾å度ãä¸ããFLUDãã¿ã¼ã³ã ãæ¸ãã¾ããã
ãã®è¨äºã¯ CodeIgniter Advent Calendar 2020 - Qiita ã®25æ¥ç®ã§ãã
CodeIgniter Advent Calendar 2020 ã®è¨äºã§ãããä»æ¥ã¯ããã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾åãããã«æ¸ããããã¨ãããã¼ãã§ãã
ãã¬ã¼ã ã¯ã¼ã¯ã®å ¥éæ¸ãå ¥éè¨äºãå ¬å¼ããã¥ã¡ã³ãã«ã¯å¤ååºã¦ããªã話é¡ã§ãã
ãã¬ã¼ã ã¯ã¼ã¯ã®ç½
CodeIgniter4 ã«ã¤ãã¦ãã¥ã¼ããªã¢ã«ããå§ãã¦ãããããã¨æ¸ãã¦ãã¾ããã
æ®éã«ã¦ã¼ã¶ã¬ã¤ããèªãã§ã¢ããªãéçºãã¦ãããã¨ããã¨ãã¢ããªã¯ä»¥ä¸ã®ããã«é層åããã¾ãã é»ãç¢å°ã¯ä¾åã§ãã
MVC ãã¿ã¼ã³
(2020-12-30 追è¨) é層ã®é åºãä¿®æ£ãã¾ããã
ä¾åã¨ã¯ããã使ãã¨ãããã¨ã§ãã
ã³ã³ããã¼ã©ãã¢ãã«ããã¥ã¼ãããã¦ãã¬ã¼ã ã¯ã¼ã¯ã«ä¾åãã¾ããã¢ãã«ããã¥ã¼ããã¬ã¼ã ã¯ã¼ã¯ã«ä¾åãã¾ãã
è¦ããã«ãã¬ã¼ã ã¯ã¼ã¯ã®ã¦ã¼ã¶ã¼ãæ¸ãã³ã¼ãã¯ã»ã¼å ¨ã¦ãã¬ã¼ã ã¯ã¼ã¯ã«ä¾åãã¾ãããã¬ã¼ã ã¯ã¼ã¯ã¨å¯çµåãã¾ãããã¬ã¼ã ã¯ã¼ã¯ããªãã¨ã»ã¨ãã©å ¨ãåãã¾ããã
æ®éã«ãã¬ã¼ã ã¯ã¼ã¯ã使ããã¨ããã¨ãèªåã®æ¸ããã³ã¼ããå¼·ããã¬ã¼ã ã¯ã¼ã¯ã«ä¾åããããã«ãªã£ã¦ãã¾ãã
ãã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾åã®åé¡ç¹
ãã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾åã®ä½ãåé¡ã§ããããï¼
ããã¯ããã¬ã¼ã ã¯ã¼ã¯ãå¤æ´ãã¥ããã¨ãããã¨ã§ããããã¯ãå¥ã®ãã¬ã¼ã ã¯ã¼ã¯ã«ç§»è¡ããã¨ãããããªå¤§ããªè©±ã ãã§ãªãããã¬ã¼ã ã¯ã¼ã¯ããã¼ã¸ã§ã³ã¢ããããã®ã大å¤ã«ãªãã¨ãããã¨ãå«ã¾ãã¾ãã
ãã¬ã¼ã ã¯ã¼ã¯ã¯ããã»ã©å®å®ãã¦ãã¾ããããã¼ã¸ã§ã³ã¯ã©ãã©ãä¸ããã¾ãããäºææ§ã®ãªãå¤æ´ããããããç¥ãã¾ããã
ãããã¯ãéçºãæ¢ã¾ã£ã¦ãã¾ãããç¥ãã¾ãããä»ã¯äººæ°ããããã¬ã¼ã ã¯ã¼ã¯ã 5å¹´ã10å¹´å¾ã¯èª°ã«ããããã¾ããã
éçºãæ¢ã¾ã£ã¦ãèªåã§ã¡ã³ããã¦ããã°ä½¿ããªããã¨ã¯ãªãã§ãããã¡ã³ãã§ããã»ã©ã®æè¡åãããã®ããªã½ã¼ã¹ãããã®ãã¨ããåé¡ãããã¾ãã
ã¢ããªã®å¯¿å½ãé·ããã°é·ãã»ã©ããã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾åã¯åé¡ã«ãªãã¾ãã
ããã§ãã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾åãããã«æ¸ãããã¨ãããã¨ãèãããã¦ãã¾ããã
ä¾ãã°ããã¯ãªã¼ã³ã¢ã¼ããã¯ãã£ãã«ã¯ã以ä¸ã®ç¹æ§ãæ¸ãã¦ããã¾ããã
- ãã¬ã¼ã ã¯ã¼ã¯éä¾å
- ãã¹ãå¯è½
- UI éä¾å
- ãã¼ã¿ãã¼ã¹éä¾å
- å¤é¨ã¨ã¼ã¸ã§ã³ãéä¾å
ADOP ãã¿ã¼ã³
ãã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾åãæ¸ããæ¹æ³ã® 1ã¤ã« ADOPï¼Application Domain Others Patternï¼ ãããã¾ãã
ADOP ã¯ä»¥ä¸ã® 3é層ã®ãã¿ã¼ã³ã§ãã
é»ãç¢å°ã¯ä¾åã§ããç½ãç¢å°ã¯æ±åãã¤ã¾ãæ½è±¡åã§ãã
ADOP ãã¿ã¼ã³
é層ã®èª¬æ
ãã¡ã¤ã³å±¤ï¼Domain Layerï¼
- ãã¡ã¤ã³é§åè¨è¨ï¼DDDï¼ã§ã®ãã¡ã¤ã³ãªãã¸ã§ã¯ããé ç½®ããé層ã§ãã
- ãã¡ã¤ã³ãªãã¸ã§ã¯ãã¨ã¯ããã¸ãã¹ã«ã¼ã«ãã«ãã»ã«åãããªãã¸ã§ã¯ãã§ãã
- ãã¡ã¯ããªããªãã¸ããªã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ãªã©ããé常ã¯ãã®é層ã«é ç½®ãã¾ãã
ã¢ããªã±ã¼ã·ã§ã³å±¤ï¼Application Layerï¼
- ãã¡ã¤ã³ãªãã¸ã§ã¯ãã使ãã¦ã¼ã¹ã±ã¼ã¹ãå®ç¾ããããã®ãªãã¸ã§ã¯ããé ç½®ããé層ã§ãã
ã¢ã¶ã¼ãºå±¤ï¼Others Layerï¼
- Domain ã«ã Application ã«ãå«ã¾ããªãæ®ãå ¨ã¦ãé ç½®ããé層ã§ãã
- ã¢ã¶ã¼ãºå±¤ã¯ãã¹ã¦ãä¸ç®æã§ç®¡çããã®ã§ã¯ãªããæè¡ã¹ã¿ãã¯ã«ãã£ã¦åå²ç®¡çãã¾ãã
MVC ãã¬ã¼ã ã¯ã¼ã¯ã¯ã©ãã¸ï¼
ADOP ã§ã¯ä»¥ä¸ã®ããã«èª¬æããã¦ãã¾ãã
MVC ãã¬ã¼ã ã¯ã¼ã¯ã¨ãã£ãã¦ã¼ã¶ã¼ã¤ã³ã¿ã¼ãã§ã¼ã¹ãå®å ¨ã«å å ãã¾ãã
ã¤ã¾ããå³ã«ããã¨ãããããã¨ã§ãã
ADOP ãã¿ã¼ã³
ä»ã¾ã§ MVC ã¨ããä¸çã§çãã¦ããæã ããããã¨è¡æçã§ãããä¸çã«ã¯ MVC 以å¤ã«ããã£ã¨å¤§åãªãã¨ããã£ãã®ã§ãï¼
ADOP ã§ã¯ãæ¢åã® MVC ã³ã¼ããã Domain 㨠Application 層ã®ã³ã¼ããåé¢ãã¦ãããã¨ããããã¾ãã
ãããã®ã³ã¼ãããã¬ã¼ã ã¯ã¼ã¯ãç¹å®ã®æè¡ã¹ã¿ãã¯ããåé¢ãããã¬ã¼ã ã¯ã¼ã¯ãç¹å®ã®æè¡ã¹ã¿ãã¯ã®å¤æ´ã®å½±é¿ããã¾ãåããªãããã«ãã¾ãã
ADOP ã®ã«ã¼ã«
ADOP ã®ã«ã¼ã«ã¯ä»¥ä¸ã® 2ã¤ã ãã§ãã
- ãªãã¸ã§ã¯ãã 3ã¤ã®é層ã®ã©ãã«åé¡ãããããèããããããã®ãã£ã¬ã¯ããªã«é ç½®ãããã¨
- ä¸ã®é層ã®ãªãã¸ã§ã¯ããä¸ã®é層ã®ãªãã¸ã§ã¯ããåãæ±ãã¨ãã«ã¯æ½è±¡åï¼ã¤ã³ã¿ã¼ãã§ã¼ã¹ï¼ã«ä¾åãããã¨
CodeIgniter4 ã§ã®ãã£ã¬ã¯ããªæ§æ
CodeIgniter4 ã§ã®ãã£ã¬ã¯ããªæ§æä¾ã¯ã以ä¸ã®ããã«ãªãã¾ãã
https://github.com/nrslib/scrum-app-sample-php ãã®ã¾ã¾ãªã®ã§ãªãã§ããã
project/
âââ app/
âââ builds*
âââ composer.json
âââ composer.lock
âââ packages/ ... packages ãã£ã¬ã¯ããªã追å
â  âââ auth/ ... èªè¨¼ããã±ã¼ã¸
â  â  âââ Application/ ... ã¢ããªã±ã¼ã·ã§ã³å±¤
â  â  âââ DebugInfrastructure/ ... ã¢ã¶ã¼ãºå±¤ï¼ãããã°ç¨ã¤ã³ãã©ï¼
â  â  âââ Domain/ ... ãã¡ã¤ã³å±¤
â  âââ basic/ ... å
±éã©ã¤ãã©ãª
â  â  âââ DebugSupport/
â  â  âââ DomainSupport/
â  â  âââ Exception/
â  â  âââ Transaction/
â  âââ scrum/ ... ã¹ã¯ã©ã ããã±ã¼ã¸
â  âââ Application/ ... ã¢ããªã±ã¼ã·ã§ã³å±¤
â  âââ DebugInfrastructure/ ... ã¢ã¶ã¼ãºå±¤ï¼ãããã°ç¨ã¤ã³ãã©ï¼
â  âââ Domain/ ... ãã¡ã¤ã³å±¤
â  âââ EloquentInfrastructure/ ... ã¢ã¶ã¼ãºå±¤ï¼Eloquentç¨ã¤ã³ãã©ï¼
âââ phpunit.xml
âââ public/
âââ spark*
âââ tests/
âââ vendor/
âââ writable/
ä½ã Domain 㨠Application ãªã®ãï¼
ã©ã®é層ã«å±ãããã®åé¡æ¹æ³ã ADOP ã§è§£èª¬ããã¦ãã¾ãã
Domain 層
- ãã¡ã¤ã³ã®äºç©ãç´æ¥çã«è¡¨ç¾ããã³ã¼ãããããã¯è¡¨ç¾ãæ¯æ´ããã³ã¼ããï¼
ãã¡ã¤ã³ã¯åé ã§ã解説ãããã¨ããã¨ãããã½ããã¦ã§ã¢ãé©ç¨ãã対象é åã®ãã¨ã§ãã ãã¨ãã°ç©æµã·ã¹ãã ã§ããã°ããã¡ã¤ã³ã®äºç©ã«ã¯ééæ段ï¼ãã©ãã¯ãªã©ï¼ãæ ç¹ãé éãªã©æ§ã ãªã¢ããã³ããããã¾ãã ãããã表ç¾ããã³ã¼ãã§ããã°ã質åã¸ã®åç㯠Yes ã«ãªãããã¡ã¤ã³ã¬ã¤ã¤ã¼ã«æå±ããã¾ãã ã¾ãããããã®ãªãã¸ã§ã¯ããæ§ç¯ããããã®ãã¡ã¯ããªãæ°¸ç¶åã®æéã示ããªãã¸ããªã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ãã表ç¾ãæ¯æ´ããã³ã¼ãã§ããããããã®è³ªåã«é¢ãã¦ã¯ Yes ã«ãªãã¾ãã
Application 層
- ãã¡ã¤ã³ã®äºç©ã表ç¾ããã³ã¼ããåãæ±ããã¦ã¼ã¹ã±ã¼ã¹ãéæããã³ã¼ããï¼
ãã¡ã¤ã³ã®äºç©ã表ç¾ããã³ã¼ãã¨ã¯ãã¡ã¤ã³ã¬ã¤ã¤ã¼ã®ãªãã¸ã§ã¯ãã®ãã¨ãæããã¤ã¾ããééæ段ï¼ãã©ãã¯ãªã©ï¼ãæ ç¹ãé éãªã©æ§ã ãªã¢ããã³ãã表ç¾ããã³ã¼ãããã¡ã¯ããªããªãã¸ããªã¨ãã£ã表ç¾ã®æ¯æ´ãè¡ããªãã¸ã§ã¯ãã®ãã¨ã§ãã ããããåãæ±ããã½ããã¦ã§ã¢ã®ã¦ã¼ã¹ã±ã¼ã¹ãéæããã³ã¼ãã§ããã°ããã®è³ªåã«å¯¾ããåç㯠Yes ã«ãªãã¾ãã
Others 層
Domain ã§ã Application ã§ããªããã®ã¯ãèªåçã« Others 層ã§ãã
ã¾ã¨ã
- ãã¬ã¼ã ã¯ã¼ã¯ã¯å¤åãæ¿ãããå¼·ãä¾åããã¨é·æã®ãµã¼ãã¹æä¾ã«æªå½±é¿ãããã¾ãã
- ãã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾åãæ¸ããæ¹æ³ã® 1ã¤ã¨ã㦠ADOP ãããã¾ãã
- ADOP ã¯ã«ã¼ã«ãå°ãªãæ¯è¼çãããããããããé©ç¨ãæ¯è¼ç容æã§ãã
- CodeIgniter4ï¼ã CodeIgniter3ï¼ã§ã ADOP ãé©ç¨ãã¦ããã¬ã¼ã ã¯ã¼ã¯ã¸ã®ä¾å度ãä¸ãããã¨ãå¯è½ã§ãã
æå¾ã«
ãã㧠CodeIgniter Advent Calendar 2020 ã¯çµããã§ãã
CodeIgniter Advent Calendar ã¯ä»ã¾ã§ 6åéå¬ããã¾ãããã25æ¥å ¨é¨åã¾ã£ãã®ã¯ä»å 2020 ãåãã¦ã§ãï¼
ä»å¹´ã¯ CodeIgniter4 ãã¤ãã«ãªãªã¼ã¹ããã¾ããï¼
lonnieezell, jim-parry, samsonasik, MGatner ããã¦å ¨ã¦ã®è²¢ç®è ã®ã¿ãªããããããã¨ãï¼
ãã®è¨äºã¯ CodeIgniter Advent Calendar 2020 - Qiita ã®25æ¥ç®ã§ãã
åè
Date: 2020/12/25