½«thinkphp3Éý¼¶Îªthinkphp5µÄÔµ¹ÊÔÓÉÓÐÄÄЩ
Ò»¡¢Ð¹¦Ð§ºÍÓÅÊÆ
ThinkPHP5ÔÚй¦Ð§ºÍÐÔÄÜ·½Ãæ´ó·ù¶ÈÌáÉý£¬Ïà½ÏÓÚThinkPHP3ÓÐÁËÏÔ×ŵÄÓÅÊÆ¡£×îÏÔÖøµÄÌصãÊǸÿò¼Ü½¹µã½ÓÄɸüÏȽøµÄÃüÃû¿Õ¼äÖÎÀí»úÖÆ£¬´Ó¶øÄܹ»ÓÐÓÃÌá¸ß´úÂëµÄ¿É¶ÁÐԺͿÉά»¤ÐÔ¡£ThinkPHP5¾ßÓиü¸ßЧµÄÎļþ»º´æºÍ¾²Ì¬»º´æ¹¦Ð§£¬ÔÚÐÔÄÜ·½ÃæÓÐ×ÅÏÔ×ŵÄÓÅÊÆ£¬Õâ¿ÉÒÔ¼«´óµØÌá¸ßϵͳÏìÓ¦ËÙÂÊ¡£±ðµÄ£¬ThinkPHP5»¹ÒýÈëÁË»ùÓÚComposerµÄÄ£¿é»¯¿ª·¢£¬Ö§³ÖÔ½·¢ÎÞаµÄÄ£¿é½ç˵ºÍÄ£¿éŲÓ㬿ÉÒԺܺõØÖª×ã´óÐÍÏîÄ¿µÄÐèÇó¡£
¶þ¡¢²©¿Íϵͳ°¸Àý
ÒÔÏÂÒÔ²©¿ÍϵͳΪÑùÀý£¬½ÏÁ¿ThinkPHP3ºÍThinkPHP5µÄÉý¼¶¶ÔÐÔÄܵÄˢС£ÒÔ×Ô¼ºµÄ²©¿ÍϵͳΪÀý£¬¸Ãϵͳ½ÓÄÉMVCÉè¼Æģʽ£¬Êý¾Ý»á¼û¹¤¾ß£¨DAO£©ÓëÊý¾Ý¿â¾ÙÐн»»¥£¬Ò²½ÓÄÉÁËSmartyÄ£°åÒýÇæäÖȾǰ¶ËÒ³Ãæ¡£²âÊÔЧ¹ûÈçÏ£º
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
Ê×ÏÈÊǼÓÔØÒ³ÃæËÙÂʲâÊÔ¡£ÎÒÃÇʹÓÃApacheBench¹¤¾ß¾ÙÐвâÊÔ£¬¶ÔÇëÇó¾ÙÐÐ5000´Î£¬Ë¼Ë÷ʱ¼äΪ500ms¡£²âÊÔЧ¹ûÊÇ£º
ThinkPHP3ƽ¾ùÏìӦʱ¼äΪ135ms£¬×îÂýÏìӦʱ¼äΪ422ms£¬ÍÌÍÂÁ¿Îª370.37 req/sec£»
ThinkPHP5ƽ¾ùÏìӦʱ¼äΪ92ms£¬×îÂýÏìӦʱ¼äΪ798ms£¬ÍÌÍÂÁ¿Îª543.48 req/sec¡£
²âÊÔЧ¹û¿´³ö£¬ThinkPHP5µÄÐÔÄÜÒªÏÔ×ÅÓÅÓÚThinkPHP3¡£
½ÓÏÂÀ´²âÊÔµÄÊÇÎÄÕÂÁбíÒ³ÃæµÄÇëÇóʱ¼ä¡£¸Ã²âÊÔÒ²ÊǽÓÄÉApacheBench¹¤¾ß£¬ÇëÇó1000´Î£¬Æä²âÊÔЧ¹ûÊÇ£º
ThinkPHP3ƽ¾ùÇëÇóʱ¼äΪ253ms£¬×ʱ¼äΪ855ms£»
ThinkPHP5ƽ¾ùÇëÇóʱ¼äΪ145ms£¬×ʱ¼äΪ329ms¡£
ͬÑùÊÇÏÔ×ŵÄÐÔÄÜÓÅÊÆ¡£
Èý¡¢¿ò¼ÜµÄ¸üкÍÉý¼¶
¿ò¼Ü¸üкÍÉý¼¶ÊÇа汾ÍƳöµÄÁíÒ»¸öÖ÷ÒªÔµ¹ÊÔÓÉ¡£ThinkPHP5Óиü´óµÄÌáÉý£¬°üÀ¨µ«²»ÏÞÓÚÀ©Õ¹ÐÔºÍ×é¼þÐÔ£¬Ïà¹ØÓÚThinkPHP3¡£¸Ã°æ±¾Ö§³ÖÁ½¸öÓ¦Óü¶±ðµÄÉèÖÃÎļþ£¨common.phpºÍconfig.php£©£¬°þÀë³ö¸ü¶àµÄ½¹µã¿âÒÔÀ©Õ¹ÁË¿ò¼ÜµÄ×é¼þÐÔ£¬ÇкÏPHPÌìÏÂÖÐÐÂÐ˵Ä×é¼þ»¯Ç÷ÊÆ¡£Ð°æ¿ò¼ÜÒ²ÔÚAPI Éè¼ÆÉÏ×öÁ˸ü¶àµÄÓÅ»¯£¬³ýÁ˸üºÃµÄ¿É¶ÁÐԺͿÉά»¤ÐÔ£¬»¹¼á³ÖÁ˺;ɰæ¼æÈݵÄͬʱÔÚ¿ª·¢ºÍ°²ÅÅÉÏÌá¸ßÁËЧÂʺÍÎȹÌÐÔ¡£
ËÄ¡¢¿ª·¢Ö°Ô±ºÍÉçÇøÖ§³Ö
ÓµÓлîÔ¾µÄÉçÇøºÍ¿ª·¢Õß¹ØÓÚÒ»¸ö¿ªÔ´¿ò¼ÜÀ´ËµÊÇÖÁ¹ØÖ÷ÒªµÄ£¬ÕâÒ»µãÊÇÎÒÃÇËùÖªµÀµÄ¡£Ëæ×Åʱ¼äµÄÍÆÒÆ£¬ThinkPHPÔÚÐí¶à·½Ã涼»ñµÃÁËÒ»Ö±µÄ¸üÐÂÉý¼¶£¬Ò²»ñµÃÁËÔ½À´Ô½¶àµÄ¿ª·¢Ö°Ô±ºÍÉçÇøµÄÖ§³Ö¡£ÀýÈ磬ThinkPHPÉçÇøÔÚµÚÈý·½×é¼þ¸»ºñˮƽ¡¢ÓµÓÐÍêÉÆTDD¹¤¾ßÁ´¼°ÎȹÌÐԵȷ½Ã涼¸üΪÓÅÒ죬ÍùÍù¿ÉÒÔÔÚһЩ¼«¶ËÇéÐÎÏÂ×ÊÖúÄúÓ¦¶ÔÎÊÌâ¡£
thinkphpÊÇʲô
thinkphpÊôÓÚÒ»ÖÖÃâ·ÑµÄ¿ª·¢¿ò¼Ü£¬Äܹ»ÓÃÓÚ¿ª·¢Ç°¶ËÍøÒ³£¬×îÔçthinkphpÊÇΪÁ˼ò»¯¿ª·¢¶ø±¬·¢µÄ£¬thinkphpͬʱҲÊÇ×ñÕÕApache2ÐÒ飬×î³õÊÇ´ÓStrutsÑݱä¹ýÀ´£¬Ò²°ÑÍâÑóһЩºÃµÄ¿ò¼Üģʽ¾ÙÐÐʹÓã¬Ê¹ÓÃÃæÏò¹¤¾ßµÄ¿ª·¢½á¹¹£¬¼æÈÝÁËÐí¶à±êÇ©¿âµÈģʽ£¬ËüÄܹ»¸üÀû±ãºÍ¿ì½ÝµÄ¿ª·¢ºÍ°²ÅÅÓ¦Óã¬ËäÈ»²»µ«½öÊÇÆóÒµ¼¶Ó¦Óã¬ÈκÎphpÓ¦Óÿª·¢¶¼¿ÉÒÔ´ÓthinkphpµÄ¼òÆÓ¡¢¼æÈݺͿìËÙµÄÌØÕ÷ÖÐÊÜÒæ¡£
ÒÔÉϾÍÊǽ«thinkphp3Éý¼¶Îªthinkphp5µÄÔµ¹ÊÔÓÉÓÐÄÄЩµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡