{"id":23021,"date":"2024-11-21T15:49:34","date_gmt":"2024-11-21T07:49:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/23021\/"},"modified":"2024-11-21T15:49:34","modified_gmt":"2024-11-21T07:49:34","slug":"tp5%e4%b8%8b%e8%bd%bd%e6%b2%a1%e6%9c%89thinkphp","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/23021\/","title":{"rendered":"tp5\u4e0b\u8f7d\u6ca1\u6709thinkphp"},"content":{"rendered":"<p>tp5\u4e0b\u8f7d\u4e2d\u6ca1\u6709thinkphp<\/p>\n<p>\u5728\u5f00\u53d1Web\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0cThinkPHP\u662fPHP\u5f00\u53d1\u4eba\u5458\u6700\u5e38\u7528\u7684\u6846\u67b6\u4e4b\u4e00\u3002\u7136\u800c\uff0c\u67d0\u4e9b\u5f00\u53d1\u4eba\u5458\u5728\u5c1d\u8bd5\u4e0b\u8f7dTP5\u65f6\uff0c\u5374\u53d1\u73b0\u65e0\u6cd5\u627e\u5230ThinkPHP\u7684\u4e0b\u8f7d\u94fe\u63a5\u3002<\/p>\n<p>\u8fd9\u53ef\u80fd\u662f\u56e0\u4e3aTP5\u4e0d\u5305\u542bThinkPHP\uff0c\u800c\u662f\u4f5c\u4e3aThinkPHP\u7684\u4e00\u4e2a\u5206\u652f\u3002TP5\u7684\u5168\u79f0\u662fThinkPHP 5\uff0c\u5b83\u7684\u5f00\u53d1\u662f\u5728ThinkPHP 3.2\u7248\u672c\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u7684\u3002\u5c3d\u7ba1\u5982\u6b64\uff0cPHP\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u4f7f\u7528TP5\u6765\u6784\u5efa\u9ad8\u8d28\u91cf\u3001\u53ef\u7ef4\u62a4\u548c\u529f\u80fd\u5f3a\u5927\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u90a3\u4e48\uff0c\u4e00\u4e2a\u6ca1\u6709\u4efb\u4f55PHP\u5f00\u53d1\u7ecf\u9a8c\u7684\u4eba\u5982\u4f55\u5b89\u88c5\u548c\u4f7f\u7528TP5\u5462\uff1f\u4ee5\u4e0b\u662f\u4e00\u4e9b\u7b80\u5355\u7684\u6b65\u9aa4\u6765\u6307\u5bfc\u60a8\u5f00\u59cb\u4f7f\u7528TP5\u3002<\/p>\n<p>\u6b65\u9aa41: \u5b89\u88c5\u672c\u5730\u670d\u52a1\u5668<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u5728\u5f00\u59cb\u4f7f\u7528TP5\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u4e00\u4e2a\u672c\u5730\u670d\u52a1\u5668\u3002\u670d\u52a1\u5668\u5c06\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u6a21\u62dfWeb\u670d\u52a1\u5668\uff0c\u4ece\u800c\u4f7f\u60a8\u80fd\u591f\u5728\u672c\u5730\u6d4b\u8bd5\u548c\u8fd0\u884cWeb\u5e94\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u6700\u53d7\u6b22\u8fce\u7684\u672c\u5730\u670d\u52a1\u5668\u4e4b\u4e00\uff1a<\/p>\n<p>XAMPP\uff1a\u5b83\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u670d\u52a1\u5668\uff0c\u652f\u6301Windows\u3001Linux\u548cMac OS\u3002\u5b83\u5305\u62ecApache web\u670d\u52a1\u5668\u3001MySQL\u6570\u636e\u5e93\u548cPHP\u89e3\u91ca\u5668\u3002<\/p>\n<p>WAMP\uff1a\u8fd9\u662f\u4e00\u4e2a\u4e3aWindows\u5f00\u53d1\u7684\u672c\u5730\u670d\u52a1\u5668\uff0c\u5305\u62ecApache web\u670d\u52a1\u5668\u3001MySQL\u6570\u636e\u5e93\u548cPHP\u89e3\u91ca\u5668\u3002<\/p>\n<p>MAMP\uff1a\u8fd9\u662f\u4e00\u4e2a\u4e3aMac\u64cd\u4f5c\u7cfb\u7edf\u5f00\u53d1\u7684\u672c\u5730\u670d\u52a1\u5668\uff0c\u5305\u62ecApache web\u670d\u52a1\u5668\u3001MySQL\u6570\u636e\u5e93\u548cPHP\u89e3\u91ca\u5668\u3002<\/p>\n<p>LAMP\uff1a\u8fd9\u662f\u672c\u5730\u670d\u52a1\u5668\u7684Linux\u7248\u672c\uff0c\u4e0eXAMPP\u548cWAMP\u7c7b\u4f3c\u3002<\/p>\n<p>\u6b65\u9aa42: \u4e0b\u8f7dTP5<\/p>\n<p>\u60a8\u53ef\u4ee5\u5728TP5\u7684\u5b98\u65b9\u7f51\u7ad9\uff08http:\/\/www.thinkphp.cn\/\uff09\u4e0a\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684TP5\u3002\u9009\u62e9\u201c\u4e0b\u8f7d\u201d\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9\u9002\u5408\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002<\/p>\n<p>\u6b65\u9aa43: \u5b89\u88c5TP5<\/p>\n<p>\u5c06\u4e0b\u8f7d\u7684TP5\u89e3\u538b\u7f29\u5230\u672c\u5730\u670d\u52a1\u5668\u7684Web\u6839\u76ee\u5f55\u4e2d\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fXAMPP\u670d\u52a1\u5668\uff0c\u5219Web\u6839\u76ee\u5f55\u7684\u9ed8\u8ba4\u4f4d\u7f6e\u662fC:<br \/>mpphtdocs\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fWAMP\uff0c\u5219Web\u6839\u76ee\u5f55\u7684\u9ed8\u8ba4\u4f4d\u7f6e\u662fC:wampwww\u3002<\/p>\n<p>\u6b65\u9aa44: \u521b\u5efa\u60a8\u7684\u7b2c\u4e00\u4e2aTP5\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684TP5\u5e94\u7528\u7a0b\u5e8f\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u76ee\u5f55\uff0c\u5e76\u547d\u540d\u4e3a\u201ctp5_test\u201d\u3002<\/li>\n<li>\u6253\u5f00\u60a8\u7684Web\u6d4f\u89c8\u5668\uff0c\u5e76\u8f93\u5165URL \u201chttp:\/\/127.0.0.1\/tp5_test\/public\/\u201d\u3002\u8fd9\u5c06\u5f00\u59cb\u5b89\u88c5TP5\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<li>\u8f93\u5165\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u3001\u5e94\u7528\u7a0b\u5e8f\u7684\u547d\u540d\u7a7a\u95f4\uff0c\u5e76\u9009\u62e9\u6570\u636e\u5e93\u7c7b\u578b\u548c\u4e3b\u673a\u540d\u3002<\/li>\n<li>\u5355\u51fb\u201c\u4e0b\u4e00\u6b65\u201d\u6309\u94ae\uff0c\u7136\u540e\u8fdb\u884c\u6570\u636e\u5e93\u8bbe\u7f6e\u3002\u8f93\u5165\u6570\u636e\u5e93\u540d\u79f0\u548c\u7528\u6237\u540d\u4ee5\u53ca\u5bc6\u7801\u4fe1\u606f\uff0c\u5e76\u5355\u51fb\u201c\u4e0b\u4e00\u6b65\u201d\u3002<\/li>\n<li>\u73b0\u5728\u60a8\u5df2\u7ecf\u8bbe\u7f6e\u597d\u4e86\u60a8\u7684TP5\u5e94\u7528\u7a0b\u5e8f\u3002\u5355\u51fb\u201c\u5f00\u59cb\u5b89\u88c5\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u5c06\u770b\u5230\u60a8\u7684TP5\u5e94\u7528\u7a0b\u5e8f\u7684\u6b22\u8fce\u9875\u9762\u3002<\/li>\n<\/ol>\n<p>\u6b65\u9aa45: \u63a2\u7d22TP5\u6846\u67b6<\/p>\n<p>TP5\u63d0\u4f9b\u4e86\u8bb8\u591a\u5e38\u7528\u7684\u5f00\u53d1\u529f\u80fd\u548c\u7ec4\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u60a8\u53ef\u4ee5\u63a2\u7d22\u7684\u7ec4\u4ef6\uff1a\u8def\u7531\u5668\u3001\u89c6\u56fe\u5f15\u64ce\u3001\u6570\u636e\u5e93\u64cd\u4f5c\u3001\u9a8c\u8bc1\u5668\u3001\u7f13\u5b58\u7b49\u7b49\u3002<\/p>\n<p>\u73b0\u5728\u60a8\u5df2\u7ecf\u77e5\u9053\u5982\u4f55\u4e0b\u8f7d\u3001\u5b89\u88c5\u548c\u4f7f\u7528TP5\u6846\u67b6\u4e86\u3002\u8fd9\u4e2a\u6846\u67b6\u53ef\u4ee5\u4e3a\u60a8\u7684Web\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u7075\u6d3b\u3001\u53ef\u7ef4\u62a4\u548c\u9ad8\u6548\u7684\u7f16\u7a0b\u73af\u5883\u3002\u5982\u679c\u60a8\u662f\u4e00\u4e2a\u65b0\u7684PHP\u5f00\u53d1\u4eba\u5458\uff0c\u5219TP5\u5c06\u662f\u60a8\u5f00\u59cbPHP\u5f00\u53d1\u7684\u7406\u60f3\u8d77\u70b9\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662ftp5\u4e0b\u8f7d\u6ca1\u6709thinkphp\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>tp5\u4e0b\u8f7d\u4e2d\u6ca1\u6709thinkphp \u5728\u5f00\u53d1Web\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0cThinkPHP\u662fPHP\u5f00\u53d1\u4eba\u5458\u6700\u5e38\u7528\u7684\u6846\u67b6\u4e4b\u4e00\u3002\u7136\u800c\uff0c\u67d0\u4e9b\u5f00\u53d1\u4eba\u5458\u5728\u5c1d\u8bd5\u4e0b\u8f7dTP5\u65f6\uff0c\u5374\u53d1\u73b0\u65e0\u6cd5\u627e\u5230ThinkPHP\u7684\u4e0b\u8f7d\u94fe\u63a5\u3002 \u8fd9\u53ef\u80fd\u662f\u56e0\u4e3aTP5\u4e0d\u5305\u542bThinkPHP\uff0c\u800c\u662f\u4f5c\u4e3aThinkPHP\u7684\u4e00\u4e2a\u5206\u652f\u3002TP5\u7684\u5168\u79f0\u662fThinkPHP 5\uff0c\u5b83\u7684\u5f00\u53d1\u662f\u5728ThinkPHP 3.2\u7248\u672c\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u7684\u3002\u5c3d\u7ba1\u5982\u6b64\uff0cPHP\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u4f7f\u7528TP5\u6765\u6784\u5efa\u9ad8\u8d28\u91cf\u3001\u53ef\u7ef4\u62a4\u548c\u529f\u80fd\u5f3a\u5927\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002 \u90a3\u4e48\uff0c\u4e00\u4e2a\u6ca1\u6709\u4efb\u4f55PHP\u5f00\u53d1\u7ecf\u9a8c\u7684\u4eba\u5982\u4f55\u5b89\u88c5\u548c\u4f7f\u7528TP5\u5462\uff1f\u4ee5\u4e0b\u662f\u4e00\u4e9b\u7b80\u5355\u7684\u6b65\u9aa4\u6765\u6307\u5bfc\u60a8\u5f00\u59cb\u4f7f\u7528TP5\u3002 \u6b65\u9aa41: \u5b89\u88c5\u672c\u5730\u670d\u52a1\u5668 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u5728\u5f00\u59cb\u4f7f\u7528TP5\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u5b89\u88c5\u4e00\u4e2a\u672c\u5730\u670d\u52a1\u5668\u3002\u670d\u52a1\u5668\u5c06\u5728\u672c\u5730\u8ba1\u7b97\u673a\u4e0a\u6a21\u62dfWeb\u670d\u52a1\u5668\uff0c\u4ece\u800c\u4f7f\u60a8\u80fd\u591f\u5728\u672c\u5730\u6d4b\u8bd5\u548c\u8fd0\u884cWeb\u5e94\u7528\u7a0b\u5e8f\u3002\u4ee5\u4e0b\u662f\u6700\u53d7\u6b22\u8fce\u7684\u672c\u5730\u670d\u52a1\u5668\u4e4b\u4e00\uff1a XAMPP\uff1a\u5b83\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u670d\u52a1\u5668\uff0c\u652f\u6301Windows\u3001Linux\u548cMac OS\u3002\u5b83\u5305\u62ecApache web\u670d\u52a1\u5668\u3001MySQL\u6570\u636e\u5e93\u548cPHP\u89e3\u91ca\u5668\u3002 WAMP\uff1a\u8fd9\u662f\u4e00\u4e2a\u4e3aWindows\u5f00\u53d1\u7684\u672c\u5730\u670d\u52a1\u5668\uff0c\u5305\u62ecApache web\u670d\u52a1\u5668\u3001MySQL\u6570\u636e\u5e93\u548cPHP\u89e3\u91ca\u5668\u3002 MAMP\uff1a\u8fd9\u662f\u4e00\u4e2a\u4e3aMac\u64cd\u4f5c\u7cfb\u7edf\u5f00\u53d1\u7684\u672c\u5730\u670d\u52a1\u5668\uff0c\u5305\u62ecApache web\u670d\u52a1\u5668\u3001MySQL\u6570\u636e\u5e93\u548cPHP\u89e3\u91ca\u5668\u3002 LAMP\uff1a\u8fd9\u662f\u672c\u5730\u670d\u52a1\u5668\u7684Linux\u7248\u672c\uff0c\u4e0eXAMPP\u548cWAMP\u7c7b\u4f3c\u3002 \u6b65\u9aa42: \u4e0b\u8f7dTP5 \u60a8\u53ef\u4ee5\u5728TP5\u7684\u5b98\u65b9\u7f51\u7ad9\uff08http:\/\/www.thinkphp.cn\/\uff09\u4e0a\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684TP5\u3002\u9009\u62e9\u201c\u4e0b\u8f7d\u201d\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9\u9002\u5408\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002 \u6b65\u9aa43: \u5b89\u88c5TP5 \u5c06\u4e0b\u8f7d\u7684TP5\u89e3\u538b\u7f29\u5230\u672c\u5730\u670d\u52a1\u5668\u7684Web\u6839\u76ee\u5f55\u4e2d\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fXAMPP\u670d\u52a1\u5668\uff0c\u5219Web\u6839\u76ee\u5f55\u7684\u9ed8\u8ba4\u4f4d\u7f6e\u662fC:mpphtdocs\u3002\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662fWAMP\uff0c\u5219Web\u6839\u76ee\u5f55\u7684\u9ed8\u8ba4\u4f4d\u7f6e\u662fC:wampwww\u3002 \u6b65\u9aa44: \u521b\u5efa\u60a8\u7684\u7b2c\u4e00\u4e2aTP5\u5e94\u7528\u7a0b\u5e8f \u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684TP5\u5e94\u7528\u7a0b\u5e8f\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u76ee\u5f55\uff0c\u5e76\u547d\u540d\u4e3a\u201ctp5_test\u201d\u3002 \u6253\u5f00\u60a8\u7684Web\u6d4f\u89c8\u5668\uff0c\u5e76\u8f93\u5165URL \u201chttp:\/\/127.0.0.1\/tp5_test\/public\/\u201d\u3002\u8fd9\u5c06\u5f00\u59cb\u5b89\u88c5TP5\u5e94\u7528\u7a0b\u5e8f\u3002 \u8f93\u5165\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u3001\u5e94\u7528\u7a0b\u5e8f\u7684\u547d\u540d\u7a7a\u95f4\uff0c\u5e76\u9009\u62e9\u6570\u636e\u5e93\u7c7b\u578b\u548c\u4e3b\u673a\u540d\u3002 \u5355\u51fb\u201c\u4e0b\u4e00\u6b65\u201d\u6309\u94ae\uff0c\u7136\u540e\u8fdb\u884c\u6570\u636e\u5e93\u8bbe\u7f6e\u3002\u8f93\u5165\u6570\u636e\u5e93\u540d\u79f0\u548c\u7528\u6237\u540d\u4ee5\u53ca\u5bc6\u7801\u4fe1\u606f\uff0c\u5e76\u5355\u51fb\u201c\u4e0b\u4e00\u6b65\u201d\u3002 \u73b0\u5728\u60a8\u5df2\u7ecf\u8bbe\u7f6e\u597d\u4e86\u60a8\u7684TP5\u5e94\u7528\u7a0b\u5e8f\u3002\u5355\u51fb\u201c\u5f00\u59cb\u5b89\u88c5\u201d\u6309\u94ae\u3002 \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u5c06\u770b\u5230\u60a8\u7684TP5\u5e94\u7528\u7a0b\u5e8f\u7684\u6b22\u8fce\u9875\u9762\u3002 \u6b65\u9aa45: \u63a2\u7d22TP5\u6846\u67b6 TP5\u63d0\u4f9b\u4e86\u8bb8\u591a\u5e38\u7528\u7684\u5f00\u53d1\u529f\u80fd\u548c\u7ec4\u4ef6\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u60a8\u53ef\u4ee5\u63a2\u7d22\u7684\u7ec4\u4ef6\uff1a\u8def\u7531\u5668\u3001\u89c6\u56fe\u5f15\u64ce\u3001\u6570\u636e\u5e93\u64cd\u4f5c\u3001\u9a8c\u8bc1\u5668\u3001\u7f13\u5b58\u7b49\u7b49\u3002 \u73b0\u5728\u60a8\u5df2\u7ecf\u77e5\u9053\u5982\u4f55\u4e0b\u8f7d\u3001\u5b89\u88c5\u548c\u4f7f\u7528TP5\u6846\u67b6\u4e86\u3002\u8fd9\u4e2a\u6846\u67b6\u53ef\u4ee5\u4e3a\u60a8\u7684Web\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u7075\u6d3b\u3001\u53ef\u7ef4\u62a4\u548c\u9ad8\u6548\u7684\u7f16\u7a0b\u73af\u5883\u3002\u5982\u679c\u60a8\u662f\u4e00\u4e2a\u65b0\u7684PHP\u5f00\u53d1\u4eba\u5458\uff0c\u5219TP5\u5c06\u662f\u60a8\u5f00\u59cbPHP\u5f00\u53d1\u7684\u7406\u60f3\u8d77\u70b9\uff01 \u4ee5\u4e0a\u5c31\u662ftp5\u4e0b\u8f7d\u6ca1\u6709thinkphp\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-23021","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=23021"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23021\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=23021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=23021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=23021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}