{"id":22939,"date":"2024-11-21T10:48:47","date_gmt":"2024-11-21T02:48:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/22939\/"},"modified":"2024-11-21T10:48:47","modified_gmt":"2024-11-21T02:48:47","slug":"%e6%80%8e%e4%b9%88%e5%9c%a8%e5%be%ae%e6%93%8e%e4%b8%ad%e5%ae%89%e8%a3%85thinkphp%e6%8f%92%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/22939\/","title":{"rendered":"\u600e\u4e48\u5728\u5fae\u64ce\u4e2d\u5b89\u88c5ThinkPHP\u63d2\u4ef6"},"content":{"rendered":"<\/p>\n<p><strong>\u4e00\u3001\u4e0b\u8f7dThinkPHP\u63d2\u4ef6<\/strong><\/p>\n<p>\u5728\u5f00\u59cb\u4f7f\u7528ThinkPHP\u63d2\u4ef6\u524d\uff0c\u6211\u4eec\u5e94\u8be5\u5148\u4ece\u5b98\u7f51\u4e0b\u8f7d\u5176\u538b\u7f29\u5305\uff0c\u5e76\u5c06\u5176\u89e3\u538b\u5230\u672c\u5730\u76ee\u5f55\u4e2d\u3002\u89e3\u538b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u6587\u4ef6\u7ed3\u6784\uff1a<\/p>\n<pre>thinkphp\/\n\u251c\u2500library\/\n\u2502&nbsp;&nbsp;\u2514\u2500think\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500cache\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500console\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500controller\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500core\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500crypt\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500db\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500debug\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500di\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500event\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500exception\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500lang\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500middleware\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500model\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500paginator\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500session\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500template\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500validate\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2514\u2500.htaccess\n\u251c\u2500.htaccess\n\u251c\u2500.travis.yml\n\u251c\u2500composer.json\n\u251c\u2500composer.lock\n\u251c\u2500CONTRIBUTING.md\n\u251c\u2500LICENSE.txt\n\u251c\u2500README.md\n\u2514\u2500think<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4e8c\u3001\u4e0a\u4f20ThinkPHP\u63d2\u4ef6<\/strong><\/p>\n<p>\u4e0b\u8f7d\u5b8cThinkPHP\u63d2\u4ef6\u540e\uff0c\u6211\u4eec\u9700\u8981\u5c06\u5176\u4e0a\u4f20\u5230\u5fae\u64ce\u4e2d\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u6211\u4eec\u9700\u8981\u5c06\u6587\u4ef6\u5939\u590d\u5236\u5230\u5fae\u64ce\u7684addons\u76ee\u5f55\u4e0b\u7684wxapp_thinkphp_plugin\u76ee\u5f55\u4e2d\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>addons\/\n\u251c\u2500wxapp_thinkphp_plugin\/\n\u2502&nbsp;&nbsp;\u2514\u2500thinkphp\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500library\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;\u2514\u2500think\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500cache\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500console\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500controller\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500core\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500crypt\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500db\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500debug\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500di\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500event\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500exception\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500lang\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500middleware\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500model\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500paginator\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500session\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500template\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500validate\/\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2514\u2500.htaccess\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500.htaccess\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500.travis.yml\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500composer.json\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500composer.lock\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500CONTRIBUTING.md\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500LICENSE.txt\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500README.md\n\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2514\u2500think\n\u251c\u2500config.php\n\u251c\u2500install.php\n\u251c\u2500logo.png\n\u2514\u2500plugin.php<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u4e0a\u4f20\u63d2\u4ef6\u540e\uff0c\u6211\u4eec\u9700\u8981\u5728\u5fae\u64ce\u7684\u63d2\u4ef6\u7ba1\u7406\u9875\u9762\u4e0a\u8fdb\u884c\u5b89\u88c5\u63d2\u4ef6\u7684\u64cd\u4f5c\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u6211\u4eec\u9700\u8981\u767b\u5f55\u5fae\u64ce\u540e\u53f0\uff0c\u8fdb\u5165\u63d2\u4ef6\u7ba1\u7406\u9875\u9762\uff0c\u627e\u5230\u540d\u4e3a\u201cThinkPHP\u63d2\u4ef6\u201d\u7684\u63d2\u4ef6\uff0c\u5e76\u5c06\u5176\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<p><strong>\u4e09\u3001\u4f7f\u7528ThinkPHP\u63d2\u4ef6<\/strong><\/p>\n<p>\u4e00\u65e6\u5b89\u88c5\u4e86ThinkPHP\u63d2\u4ef6\uff0c\u6211\u4eec\u4fbf\u53ef\u4ee5\u5728\u5fae\u64ce\u4e2d\u4f7f\u7528\u5176\u6240\u63d0\u4f9b\u7684\u529f\u80fd\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u63d2\u4ef6\u7684\u63a7\u5236\u5668(Controller)\u4e2d\u5b9a\u4e49\u76f8\u5e94\u7684\u65b9\u6cd5\uff0c\u4ee5\u4f9b\u5176\u4ed6\u6a21\u5757\u6216\u63d2\u4ef6\u4f7f\u7528\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u63d2\u4ef6\u7684Controller\u4e2d\u5b9a\u4e49\u5982\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<pre>public&nbsp;function&nbsp;hello()\n{\n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;'hello,thinkphp';\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7136\u540e\uff0c\u5728\u5176\u4ed6\u6a21\u5757\u6216\u63d2\u4ef6\u7684Controller\u4e2d\uff0c\u5c31\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u65b9\u5f0f\u8c03\u7528\u8be5\u65b9\u6cd5\uff1a<\/p>\n<pre>$thinkphpPlugin&nbsp;=&nbsp;$this-&amp;gt;createPlugin('wxapp_thinkphp_plugin');\necho&nbsp;$thinkphpPlugin-&amp;gt;hello();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8c03\u7528createPlugin\u65b9\u6cd5\u65f6\uff0c\u6211\u4eec\u9700\u8981\u6307\u5b9a\u8be5\u65b9\u6cd5\u6240\u5c5e\u7684\u63d2\u4ef6\u7684\u76ee\u5f55\u540d\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06ThinkPHP\u63d2\u4ef6\u7684\u76ee\u5f55\u540d\u8bbe\u7f6e\u4e3awxapp_thinkphp_plugin\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u5728\u5fae\u64ce\u4e2d\u5b89\u88c5ThinkPHP\u63d2\u4ef6\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>\u4e00\u3001\u4e0b\u8f7dThinkPHP\u63d2\u4ef6 \u5728\u5f00\u59cb\u4f7f\u7528ThinkPHP\u63d2\u4ef6\u524d\uff0c\u6211\u4eec\u5e94\u8be5\u5148\u4ece\u5b98\u7f51\u4e0b\u8f7d\u5176\u538b\u7f29\u5305\uff0c\u5e76\u5c06\u5176\u89e3\u538b\u5230\u672c\u5730\u76ee\u5f55\u4e2d\u3002\u89e3\u538b\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u6587\u4ef6\u7ed3\u6784\uff1a thinkphp\/ \u251c\u2500library\/ \u2502&nbsp;&nbsp;\u2514\u2500think\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500cache\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500console\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500controller\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500core\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500crypt\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500db\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500debug\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500di\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500event\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500exception\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500lang\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500middleware\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500model\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500paginator\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500session\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500template\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500validate\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2514\u2500.htaccess \u251c\u2500.htaccess \u251c\u2500.travis.yml \u251c\u2500composer.json \u251c\u2500composer.lock \u251c\u2500CONTRIBUTING.md \u251c\u2500LICENSE.txt \u251c\u2500README.md \u2514\u2500think \u767b\u5f55\u540e\u590d\u5236 \u4e8c\u3001\u4e0a\u4f20ThinkPHP\u63d2\u4ef6 \u4e0b\u8f7d\u5b8cThinkPHP\u63d2\u4ef6\u540e\uff0c\u6211\u4eec\u9700\u8981\u5c06\u5176\u4e0a\u4f20\u5230\u5fae\u64ce\u4e2d\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u6211\u4eec\u9700\u8981\u5c06\u6587\u4ef6\u5939\u590d\u5236\u5230\u5fae\u64ce\u7684addons\u76ee\u5f55\u4e0b\u7684wxapp_thinkphp_plugin\u76ee\u5f55\u4e2d\uff0c\u5982\u4e0b\u6240\u793a\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b addons\/ \u251c\u2500wxapp_thinkphp_plugin\/ \u2502&nbsp;&nbsp;\u2514\u2500thinkphp\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500library\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;\u2514\u2500think\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500cache\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500console\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500controller\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500core\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500crypt\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500db\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500debug\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500di\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500event\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500exception\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500lang\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500middleware\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500model\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500paginator\/ \u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u2502&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u251c\u2500session\/ [&hellip;]<\/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-22939","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22939","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=22939"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22939\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=22939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=22939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=22939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}