CodeIgniterãæ¥æ¿ã«ãããªã£ã¦ãã
CodeIgniterãè©ä¾¡ãã¾ããã
ç³ã訳ãªããã©ããã®ããã°ã¨ã³ããªã®èè
ãå¦çããã ã¨ç¥ãã¤ã¤ããã¤ãæ¹å¤ãã¾ãã
CodeIgniterの嫌な部分 | Oddwit
æ巨大æ²ç¤ºæ¿ã§ãããã®ããã°ã¨åããããªè°è«ãããã¾ããã
ãããæ¹å¤ãããã¨ããCodeIgniterã®è¯ããä¸æã説æããæ¹æ³ã§ããã¨åæã«ã誤解ã解ãæ¹æ³ã ã£ãã®ã§ããããã¦æªæã¯ããã¾ãããéã«ã注ç®ãã¹ãæãæãã¦ãããã¦æè¬ãã¦ãã¾ãã
ãã®ããã°ã¨ã³ããªãGoogleã®æåãã¼ã¸ã«ç»å ´ããçµæã
KohanaフレームワークでPHPTALを利用してみた - せつないぶろぐ
ã®ããã«å½±é¿ããã人ããã¾ããã
åãããã«èãã人ã¯æ°å¤ãããããã§ãããå½¼ãã®åå¨ã¯ç¹å®ã§ããªãã®ã§ãç¹å®ã§ãã人ã«â¦ããããã»ãã¨ç³ã訳ãªããã§ããè¨ããªãã¨ããããããã®ãã¼ã¸ãæ¤ç´¢çµæã®æåã«è¡¨ç¤ºãã¦ãã¾ãGoogleã®ã¬ã¼ãã£ã³ã°ã«ç½ªãããããããã¯ã
ParserãSmartyãããªã
ããã§Parserã¨å¼ãã§ããã®ã¯ããããããã³ãã¬ã¼ãè¨èªå¦çç³»ã®ãã¨ã ã¨æãã
éçºããã»ã¹ã ä½ã ã¨æºä¸ã®ç©ºè«ãèªããªãç¾å®ä¸»ç¾©è
ãã¡ã¯ãSmartyãæãã¦ãã<?=...?>ã{...}ã«ç½®ãæããã ãã®å¹æãããªããã®ãã ã¨è¨ãããã³ãã¬ã¼ãã¨ã³ã¸ã³ã®ãã¯ãè¨èªã§ãã³ãã¬ã¼ãã¨ã³ã¸ã³ãå®è£
ãããªã©ã¨ãã馬鹿ãããã®ã好ã¾ããçç±ããç§ã«ããã£ã±ãç解ã§ããªããï¼æ®éã¯Smartyã¯å«ããè
ã§ãã§ããç¹å®ã®æ¡ä»¶ä¸ã§ã¯ãªãã¦ã¯ãªããªããã®ãã ã¨æããã ãã©ãï¼
éçºä¸ãªããææ°ãã¹ã¯ãããPCã®CPUãã¯ã¼ãèªåã²ã¨ããç¬å ãã¦ãããã©ããªãªã¼ã¹å¾ã¯ã100ã1000ããæ¸ã¾ãªãæ°ã®ã¦ã¼ã¶ããä»ã«è¤æ°ã®ãµã¼ãã¹ãåæã«æä¾ãã¦ãããµã¼ã(é·ãæ¥åãç¶ãã¦ãã顧客ã®ç°å¢ã»ã©ãä½ä¸ä»£ãæ§ãUnixã§ãããã¨ãå¤ã)ã«éã¾ãã¨ããã®ã«ã
ãªã®ã§ãPHPã¨ãããã³ãã¬ã¼ãã¨ã³ã¸ã³ãããã©ã«ãã®è¡¨ç¤ºç³»ã¨ããã®ã¯ãå
¨ãæ£ãããã³ã¹ãã«ç ç²ãæã£ã¦ã§ãSmartyãå¿
è¦ãªå ´åã«ã¯ããã¶ããã®ããã«æ¡å¼µãããã¨ã¯å¯è½ãã§ãããã®éã¯å¤åä¸å¯è½ã
ã³ã¼ãã®åé¢ãèªå好ã¿ã«ãªãããã¨ããçç±ã ãã§ãç¡æ¡ä»¶ã«CPUã馬鹿é£ããã¦ããéçã¯ãªããã³ã¼ãã®åé¢ã§é¸ãã§ãããªããããããPHPèªä½ãé¿ãããã¢ããªã±ã¼ã·ã§ã³ãµã¼ãã®ã¡ã¢ãªã«å¸¸é§ã§ãããã³ãã¬ã¼ãã¨ã³ã¸ã³ã§ãããé«å°ãªãã¥ã¼æè¡ã使ãã®ãæ£ãããPHPãæãä¸æã使ãæ¹æ³ã¯ããæ±ãããã¨ä½ã ããã¨ãã¨ã«ããæ£ããåãã°ãããã¨ãã妥åãç©æ¥µçã«åãå
¥ãããã¨ã ã¨æãã
ã»ãã·ã§ã³ãã¯ããã¼ã«ç´æ¸ããã
PHPã®ã»ãã·ã§ã³ã¯ç¹å®ã®æ¡ä»¶ä¸ã§ãã使ããªããééã£ãç¶æ³ã§é¸æããã¨ãè´å½çãªåé¡ãå¼ãèµ·ããå¯è½æ§ããããã¨ããã§ãPHPããã使ãããæ¡ä»¶ï¼å
¬éãããWebãµã¤ããä¸å°ä¼æ¥ã®æ¥åç³»Webçªå£ï¼ã§ã¯ããããPHPã®(J2EEä»æ§ã®ãµãã»ãããª)ã»ãã·ã§ã³ãåãã¦ããªãå ´åã®æ¹ãå¤ãã
ãã£ã½ããã¯ã©ã¤ã¢ã³ããµã¤ãã»ãã·ã§ã³ã¯ããããä¸è½ã§ãã¨ãã«ä¸ç¹å®å¤æ°ãç¸æã«ããã¨ããæè¯ã®é¸æã¨ãªããã»ãã·ã§ã³ãã¼ã¿è¥å¤§åã§ãµã¼ããã¯ã©ãã·ã¥ããããã¯ãå°æ°ã®ã¦ã¼ã¶ã«ä¸å
·åçºçããã»ããã¾ã ãã·ã ãPHPããå¤ãã®ã»ãã·ã§ã³æ
å ±ãä¿æããã¡ãªJavaã§ã¯ãã»ãã·ã§ã³ã®è¥å¤§åã§æ¥åã·ã¹ãã ã®ã¯ã©ãã·ã¥ãèµ·ãã£ã¦ããã
ãããã¾ãããã³ãã¬ã¼ãã¨ã³ã¸ã³ã¨åæ§ã ãã¯ããã¼ã使ãã°ã»ãã·ã§ã³ãå®è£
ã§ããããã»ãã·ã§ã³ãæåããå¼·å¶ããã¦ããã¨éãéããªãããã¡ã¤ã³ç¹åãªãµã¼ããµã¤ãã»ãã·ã§ã³ã®å®ç¾ã¯ç°¡åã ããµã¼ãå´ã®ãã¼ã¿ãã¼ã¹ã«ã¦ã¼ã¶æ¯ã®ä½æ¥ç¨ã¬ã³ã¼ããä½ãããã®IDãã¯ããã¼çµç±ã§ã¦ã¼ã¶ã«æä¾ããã°ãããã©ããã¦ãå¿
è¦ãªãã®ã«ã ãããããããã°ããã
ã¡ãªã¿ã«ãããã©ã«ãè¨å®ã¯ã¯ããã¼ä¿åã ãã©ãè¨å®ãå¤ããã°ãSQLã§ã»ãã·ã§ã³ã¤ã³ã¹ã¿ã³ã¹ãä¿åãããã¨ãã§ããããã¼ã«ã«ãã¡ã¤ã«ã«ä¿æããããã¯ã ãã¶ãã·ã
ã»ãã·ã§ã³ã§ç°¡åã«èªçã§ããããã°ã©ã ãå®æã«ä½ããã¦ãã¾ããªããããããã©ã«ããå®å
¨å´ã«ãªã£ã¦ãããã¨ã¯ãããã好å°è±¡ãApache MyFacesãããã©ã«ãã§ã¯ã©ã¤ã¢ã³ããµã¤ãã»ãã·ã§ã³ãRailsã2.0ãããã¡ã¤ã«ã·ã¹ãã ã«ã»ãã·ã§ã³ãæããªããããã
ããããã°ãæ巨大æ²ç¤ºæ¿ã§ããCIã¯ã¯ããã¼ãã¡ãªãã©ã¦ã¶ã§ä½¿ããªãããå«ãã»ãã·ã§ã³ã欲ãããã¨ããçºè¨ãè¦ããããã¯ããããç¬ããªã人ã¯ã絶対ã«ä»äºã§Webã¢ããªã±ã¼ã·ã§ã³æ¸ããªãããã«ã
ã»ãã·ã§ã³ãèªã¿æ¸ãããã¡ã½ããåãé·ã
CIã®ã»ãã·ã§ã³ã¯ãHTTPè¶ãã®æç¶çãªå¯¾è©±å ¨è¬ã表ç¾ãããããã ãPHPã®ãããªãç¹å®æ©è½ã«ãã¾ãã¾ã¢ãµã¤ã³ããååã§ã¯ãªãããªã®ã§ãã»ãã·ã§ã³ãªãã¸ã§ã¯ãã«ã¯è¤æ°ã®è²¬åããããè¤æ°ã®è²¬åãã²ã¨ã¤ã®ã¯ããã¼ã¨ããã¡ã«ããºã ãå ±æããããªã®ã§ãã¦ã¼ã¶ãã¼ã¿ã®åå¾ã¨æ ¼ç´ã¨ãä»ã®ã¯ããã¼ã使ã£ãæ©è½ã¨ãæ示çã«åºå¥ã§ãããã¨ã¯æé£ãããã¬ã¼ã ã¯ã¼ã¯ãæ¡å¼µãã¦ã¦ã¼ã¶ãã¼ã¿ã§ã¯ãªãå±æ§ãã»ãã·ã§ã³ã«å ãããããã¢ããªã±ã¼ã·ã§ã³å®è£ ã¨ã®ååè¡çªãå¿é ããªãã¦æ¸ãã
ããªãã¼ã·ã§ã³ãããµã
ã¾ãã©ã¤ãã©ãªã®ã¡ã½ããã®ä¸èº«ã«ã$_POSTãããã¼ãã³ã¼ãã£ã³ã°ããã¦ãããããä»»æã®å¤æ°ãããªãã¼ãã§ããªãã
ããªãã¼ã·ã§ã³ã¯ãä½ããã®å¢çã§ãæ£ä½ä¸æãªå¤é¨ã®ãã¼ã¿ããå
é¨ã§ä½¿ããå½¢å¼ï¼åï¼ã«å¤æãã試ã¿ãã®ãã¨ããã£ããééã£ã¦ãã人ãå¤ããã©ã主é¡ã¯ãå¤æãã§ãã£ã¦ããæ¤æ»ãã§ã¯ãªããæ¤æ»ã¯ããªãã£ã±ã¼ã·ã§ã³ã¨è¨ãããã¦ãWebã§æ£ä½ä¸æãªãã¼ã¿ã¨ã¯ä½ããããã¤ã¯ãã¹ããã¼ã¿ã®ãã¨ã ãèªåã§ä½ã£ãå¤ãããã§ã«ä¿æãã¦ãããã¼ã¿ã¯æ£ä½ãããã£ã¦ããã®ã§ãããããæ¯è¼ç
§åãã¦ãã(Webã®å
¥åºåå¢çã«ããã¦ã¯)ããªãã¼ã·ã§ã³ã¨ã¯å¼ã°ãªããåã«ããã¼ã¿ä¸æ´åã®ã¨ã©ã¼ã¨è§£éããã¹ãã
ãããã«ããã¹ããã¼ã¿ã®ããªãã¼ã¿ã«å«ã¾ãããã§ãã¯ã«ã¼ãã³ãåå©ç¨ãããæã¯ããããWebãã¬ã¼ã ã¯ã¼ã¯ã®ããªãã¼ã¿ãæã¤è²¬åã¯ãå¤é¨ããã®å¤æ°ãå®å
¨ã«æã¡è¾¼ããã¨ã ãããã¯ãèªåãå¿
è¦ã¨ãã¦ããæ¤æ»ã¨åãã ãããï¼èªåã®ã¢ããªã±ã¼ã·ã§ã³ã®ãã¼ã¿ã«ã¯èªåã§è²¬ä»»ãæã¤ã®ããé©åãªè²¬ååæ
ã ã¨æãã
ããã¦ãã¨ã©ã¼ã¡ãã»ã¼ã¸ãå¤æ°ã§åå¾ããã¨ããã©ã«ãã§<p>ã</p>ã«å²ã¾ãã¦æ¥ãã¨ããé©ãã®ããµããçºæ®ãã¦ãããã
ãã¹ããã¼ã¿ã®ããªãã¼ã·ã§ã³ã¨ã©ã¼æååãä»»æã®æååã§ã©ããã§ããã®ã¯æé£ãã
<?php if (array_key_exists('hoge', $errors)) { ?> <span class="error"><?=$errors['hoge'] ?></span> <?php } ?>
ãã®ãã¿ã¼ã³ã
<?=$this->validation->hoge_error ?>
ããæ¸ãããããã©ããããããªããã°ã空æååã§ã©ããããã°ããã
以ä¸ãããã§åã£ã¦ããã¾ãã大äºãªãã¨ã¯è¨ãã¾ããã
CIãåãã§ãã人ã¯ãããããããããWebæè¡ã使ãåãããã¨ãã§ããã¹ãã«ãæã£ããæ¬å½ã®ç¾å®ä¸»ç¾©è ã ã¨æããå½¼ãã¯ããããé«åº¦ã¨ãããæè¡ãæã£ã¦ãããã¨ããç®ã®åã®ç¾å®åé¡ã解決ããã®ã«å¦¥å½ãªæè¡ãé¸ã¶ãå½¼ããããã¦PHPãé¸ã¶ã¨ããå¤ãã®å ´åããä»çãã®è±ªè¯ãªãã¬ã¼ã ã¯ã¼ã¯ãé¿ããããªãã£ã¦ãRoRã®ããã«PHPãæ¸ãããããªããæåããRoRã使ãã°ãããã ãããã¨ããã§CIã¯ã¨ããã¨ãããããããã¡ã¤ã³ç¹åãã¬ã¼ã ã¯ã¼ã¯ãå ±éãã¦å®è£ ããããªãã®ããããã¯ãå®è£ ãå¿ããããªãã®ããããç¨åº¦ã¾ã¨ãã¦æä¾ãã¦ããããä½è¨ãªãã®ã¯é¿ããããã足ããªããã®ã¯ä½ãã°ãããçã®PHPã«ã¯è¶³ããªããã®ã ããã§ããããã«ã¼ãããä½ãã°ãããã ãã©ãããèªåãä½ããã®ã¨åããã®ããã§ã«åå¨ãããã®ã³ã¼ãã®æ¹ãæ¯ãã¦ãããªãã使ããã¦ããã£ã¦æ¥½ãããã£ã¦çºæ³ããããè·æ¥ããã°ã©ãã®è¦ç¹ã
CIã«éãããä»äººã®æ¹æ³ã«èªåãéåæãè¦ããã¨ããåã«ããããããã¨ã ãèãã¦åãæ¨ã¦ã¦ããã¨çå®ãè¦éããããããªä»æ§ã ã¨æãã°æãã»ã©ãããªããããªã£ããããèãããã¨ã¯éè¦ãåºæ¬çã«ãæ¹å¤ãããå´ã®å¤ãã¯ãæ¹å¤ããå´ããåªç§ã ã¨ãããã¨ãå¿ããã¨æ¥ããããããããªä»æ§ã®åå ã®ã»ã¨ãã©ã¯ã
- ä½è ããèªåãäºæ®µé以ä¸é ãã¦ãã¦ãç®çãç解ã§ããªããã
- çµç¹ã¨ããéåç¥ï¼ãã¦ãã¦å人ããç¥è½ãå£ãï¼ã®æããã度ãè¶ãããã
ãã®ã©ã¡ããã ã