ããã«ã¡ã¯ãCTOã®@itoshoã§ãã
å¤ã®ç²ååãå§ã¾ã£ã¦ãã¾ãããã©ã³ãã®æéã¯SPORTS BULLããã®ã¢ããªã§ãã¼ãã£ã«é«æ ¡éçã観ã¦ãã¾ãã ã¨ããããã§ããã¬ãã·ã¥ãªé«æ ¡çå ã«è² ããªãããã«ãã¬ãã·ã¥ãªCakePHP4ã§ç¤¾å ãã¼ã«ãã¤ãã£ã話ããããã¨æãã¾ãã
ãªããCakePHP4ã§ã¤ãã£ãã®ï¼
ç¾å¨ãã³ãããã®ããã¯ã¨ã³ãã®ã·ã¹ãã ã¯CakePHP3ç³»ã主æµã«ãªã£ã¦ãã¾ãããµã¼ãã¹ãæ¡å¤§ãã¦ããä¸ã§ä»å¾ä»ã®è¨èªããã¬ã¼ã ã¯ã¼ã¯ãå°å ¥ãã¦ããå¯è½æ§ã¯ããã¾ããã社å ã«PHPåã³CakePHPã®ãã¬ãã¸ãèç©ããã¦ããã®ã§ãå½é¢CakePHPãã³ãããã®æè¡ã¹ã¿ãã¯ã®ä¸»è»¸ã®ä¸ã¤ã§ãããã¨ã¯å¤ãããªãã¨èãã¦ãã¾ããããããã¨ãCakePHP3ããCakePHP4ã¸ã¢ããã°ã¬ã¼ããã¦ããã®ã¯å½ç¶ã®æµãã§ãã®ã§ãæ©ãã«CakePHP4ã触ã£ã¦ããããã¨æãã¾ããã
ããããCakePHP4ã¯ã¾ã stableçããªãªã¼ã¹ããã¦ãããã4.0.0 beta1ãææ°ã®ãã¼ã¸ã§ã³ã«ãªãã¾ãã*1ã§ãã®ã§ããã¡ãããããã¯ã·ã§ã³ç°å¢ã¸ã®å°å ¥ã¯ãªã¹ã¯ãããã¾ãããããã社å ãã¼ã«ã§ããã°ããç¨åº¦ãã®ãªã¹ã¯ã許容ãããã¨ãåºæ¥ã¾ããããããããã°ãè¸ãã°CakePHPã«ã³ã³ããªãã¥ã¼ãåºæ¥ããã£ã³ã¹ãããã¨èããä»åCakePHP4ãæ¡ç¨ãããã¨ã«ãã¾ããã
ã©ããããã¼ã«ãã¤ãã£ãã®ï¼
ãã®ç¤¾å ãã¼ã«ã«ã¤ãã¦ã¯ãã¾ãå¥ã®æ©ä¼ã«è©³ããç´¹ä»ãããã¨æãã¾ããã¤ãã£ããã®ã¯ä»¥ä¸ã®ãããªã·ã³ãã«ãªwebã¢ããªã±ã¼ã·ã§ã³ã§ãã
- ç»é¢æ°: 12
- ãã¼ãã«æ°: 5
- æ©è½ã®ã»ã¨ãã©ãã·ã³ãã«ãªCRUDå¦ç
ééæéã§éçºãã¦ããã®ã§å®æããã¾ã§1ã¶æå¼±ããããããã¾ããããã¬ãããªæéãåããã¨ãåºæ¥ãã°2ã3æ¥ã§å®æåºæ¥ãããªã¥ã¼ã ããªã¨æãã¾ãã
CakePHP4ã©ãï¼
ä¸è¿°ã®éããã»ã¨ãã©ã®æ©è½ãbakeã®èªåçæãã¦ãããã³ã¼ãã«æ¯ãçããã¬ãã«ã§ãã¬ãããªä½¿ãåããããã§ã¯ããã¾ãããã§ãã®ã§ãä»å¾ã¾ãå¥ã®å°è±¡ãæã¤ããããã¾ããããä¸ã¤ã®webã¢ããªã±ã¼ã·ã§ã³ãã¤ãã£ãå°è±¡ã¨ãã¦ã¯ãCakePHP3ã«æ £ãã¦ããã°ããããªãå ¥ã£ã¦ããããã¨æãã¾ããã
ããã¦ãCakePHP4.0ã®ãã¼ãããããèªãã¨ãåé ã«ä»¥ä¸ã®ãããªè¨è¿°ãããã¾ãã
CakePHP 4.0 will be a breaking change from 3.x. Unlike 3.0, 4.0 will primarily be a clean-up release. Instead of introducing large backwards incompatible changes, 4.0.0 will focus on removing all the deprecated features we've accumulated throughout the life of 3.x. Any method/feature emitting run-time warnings in 3.6 will be removed from 4.0. 4.0 will not add significant new features as the bulk of the release will be spent on cleanup efforts.
è¦ç´ããã¨ã4.0ã¯2ç³»ãã3ç³»ã®æã®ãããªç ´å£çãªå¤æ´ããããéæ¨å¥¨æ©è½ã®åé¤ãä¸å¿ã«è¡ããå¾æ¹äºææ§ã®ãªãæ°æ©è½ã¯æ¬¡ã®4.1ã§è¡ãã¨ããæ¹éã«ãªã£ã¦ãã¾ããã¤ã¾ãã4.0ã¯4ç³»ã«ã½ããã©ã³ãã£ã³ã°ããããã®ãªãªã¼ã¹ã«ãªã£ã¦ããã®ã§ããããªãå ¥ã£ã¦ããããã¨ããææ³ãæã¤ãã¨ãåºæ¥ãã¨ããããã§ãã*2
ãã®ä¸ã§ããã£ï¼ãã¨æã£ãã¨ãããç°¡åã«ç´¹ä»ãã¾ãã
- ãã³ãã¬ã¼ããã¡ã¤ã«ãctpãã¡ã¤ã«ããphpãã¡ã¤ã«ã«ãªã£ã
- ããããä¸çªæåã«æ°ä»ãã®ããã®å¤æ´ã§ã¯ãªãã§ãããããæ¡å¼µåãå¤ãã£ãã ãããããã¾ããããPHPStorm使ãã¨ãã¦ã¯ç¹å¥ãªè¨å®ãããã«ãPHPãã¡ã¤ã«ã¨ãã¦æ±ããããã«ãªãã¾ããã
- ããã©ã«ãã¬ã¤ã¢ã¦ãã«Milligramãæ¡ç¨ããã
- Milligramã¯ä½åº¦ã使ã£ããã¨ãããã¾ããã軽ããããã¶ã¤ã³æ§ãé«ãããã«ã¹ã¿ãã¤ãºãããããã®ã§å人çã«ã¯å¬ããå¤æ´ã§ããã
- ãªã½ã¼ã¹ã®ã«ã¼ãã£ã³ã°ã®ã«ã¼ã«ãä¸é¨å¤æ´ã«ãªã£ã
- è¤æ°ã®åèªãããªããä¾ãã°
TodoItemsController
ãä½æããå ´åãããã¾ã§ã¯todo_items
ã¨ããã«ã¼ãã£ã³ã°ã§ãããtodo-items
ã¨ããã«ã¼ãã£ã³ã°ã«ãªãã¾ããããªããããã¾ã§éãã¢ã³ãã¼ã¹ã³ã¢å½¢å¼ã«ãããå ´åã¯ãªãã·ã§ã³ã§'inflect' => 'underscore'
ãæå®ãã¾ãã
- è¤æ°ã®åèªãããªããä¾ãã°
- ï¼bakeã§ã³ã¼ãã®èªåçæãããã¨ï¼æ»ãå¤ã®åã宣è¨ããããã«ãªã£ã
- å人çã«ã¯ãããä¸çªå¬ãããªã¨æãã¾ããï¼å¥ã«å ããæ¸ããã¨æãã°æ¸ããã®ã§ãããããã¾ã§CakePHPæ¬ä½ãæ»ãå¤ã®å宣è¨ããã¦ããªãã£ãã®ã§ãããã«è¿½å¾ããå½¢ã§ã³ãããã§ã¯ã¢ããªã±ã¼ã·ã§ã³ã³ã¼ãå´ãæ¸ãã¦ããªãã£ãã®ã§ãããCakePHP4ããã¯æ°ã«ãããã¨ãªãæ»ãå¤ã®åã宣è¨åºæ¥ããã¨ã«ãªãããã§ãã
- ï¼bakeã§ã³ã¼ãã®èªåçæãããã¨ï¼strictã¢ã¼ããæå®ãããããã«ãªã£ã
- ãããããã¿ã¤ãã»ã¼ããªã³ã¼ããå®ç¾ããããã®ä¸ç°ã§ãããstrictã¢ã¼ãã®æåã«ã¤ãã¦ã¯ä»¥åQiitaã«ã¾ã¨ããè¨äºãããã®ã§ãããèå³ãããã°ä½µãã¦ã覧ãã ããã
newEmptyEntity()
ã¡ã½ããã®ç»å ´- ããã¾ã§æ°ããEntityãä½æããæã¯
newEntity()
ã¡ã½ãããå©ç¨ãã¦ããã®ã§ãããbakeã§èªåçæãããã³ã¼ããã¿ãã¨ä»å¾ã¯newEmptyEntity()
ã¡ã½ãããå©ç¨ããã»ãããã¿ã¼ã®ããã§ããæåéã空ã®Entityãä½æããã¡ã½ãããªã®ã§ããnewEmptyEntity()
ã¡ã½ããã¨ã®éãã¯Entityçææã«ããªãã¼ã·ã§ã³ãè¡ããè¡ããªããã®éããããã¾ãï¼newEmptyEntity()
ã¡ã½ããã¯ããªãã¼ã·ã§ã³ãè¡ããªãï¼ã
- ããã¾ã§æ°ããEntityãä½æããæã¯
ãã¾ããCakePHP4ã使ãã«ã¯ï¼
ããã¾ã§èªãã§ãä»ããç§ãCakePHP4ã使ã£ã¦ã¿ããï¼ã¨æã£ã¦ãããæ¹ã¯ã以ä¸ã®ã³ãã³ãã§ããã¸ã§ã¯ãã®ä½æãå¯è½ã§ããã¡ãªã¿ã«ãCakePHP4ããPHP7.2以ä¸ãå¿ è¦æ¡ä»¶ã«ãªã£ã¦ãã¾ãã®ã§ã注æãã ããã
$ composer create-project --prefer-dist cakephp/app:4.x-dev app
åé ã«è¿°ã¹ã¾ããããCakePHP3ã«æ £ãã¦ããã°ããããªãå ¥ã£ã¦ããã¾ãããä¸è¨ã«æãããããªããããæ¹åãå«ã¾ãã¦ããã®ã§stableçãåºããããããã¯ã·ã§ã³ã³ã¼ãããªãã¹ãæ©ãã«ã¢ããã°ã¬ã¼ããã¦ããããï¼ã¨ããæ°æã¡ãæ°ãã«ãã¾ãããã¾ããããã¯CakePHP4ã«éã£ã話ã§ã¯ãªãã§ããããã¯ãã¡ãã£ã¨ãããããã¿ã¤ãçãªwebã¢ããªã±ã¼ã·ã§ã³ãã¤ããããæã«é常ã«ä½ã³ã¹ãã§åºæ¥ãç¹ã¯æ¹ãã¦æé«ã ãªã¨æãã¾ããã*3
ã¨ããããã§ãä»å¾ãCakePHPã¨å ±ã«ã人ã®çæ´»ã«ãªãã¦ã¯ãªããªããã®ããã¤ãã£ã¦ããããï¼ä¸ç·ã«ã¤ãã£ã¦ããã仲éã絶è³å¤§åéä¸ã§ãï¼
åèãµã¤ã
- 4.0 Roadmap · cakephp/cakephp Wiki · GitHub
- https://book.cakephp.org/4.0/en/appendices/4-0-migration-guide.html
- https://bakery.cakephp.org/2019/06/29/cakephp_400beta1_released.html
- 今からちょっとだけ先の未来、CakePHP4の話 〜Upcoming CakePHP Roadmap & Releases〜 - コネヒト開発者ブログ
*1:2019å¹´8æ13æ¥ç¾å¨
*2:è¨ãã¯æãè¡ãã¯é£ãã ã¨æãã®ã§ããããå®ç¾ãã¦ããã¦ããCakePHPã³ã¢ãã¼ã ã®çããã¯æ¬å½ã«åãã¨æãã¾ãã
*3:å®ã¯å½åGoÃReactã§SPAã£ã½ãã¤ãããã¨æã£ãã®ã§ãããã¤ãããããã®ã«å¯¾ãã¦è¥å¹²ãªã¼ãã¼ã¨ã³ã¸ãã¢ãªã³ã°æããã£ãã®ã§ãè¾ããã¨ããçµç·¯ãããã¾ãã