{"id":23093,"date":"2024-11-21T08:00:56","date_gmt":"2024-11-21T00:00:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/23093\/"},"modified":"2024-11-21T08:00:56","modified_gmt":"2024-11-21T00:00:56","slug":"%e6%80%8e%e4%b9%88%e7%94%a8thinkphp%e6%96%b0%e5%bb%ba%e9%a1%b9%e7%9b%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/23093\/","title":{"rendered":"\u600e\u4e48\u7528thinkphp\u65b0\u5efa\u9879\u76ee"},"content":{"rendered":"<p>thinkphp \u662f\u4e00\u4e2a\u5f00\u6e90\u7684 php \u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u7ec4\u4ef6\u548c\u5de5\u5177\uff0c\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u6784\u5efa\u9ad8\u6548\u3001\u7a33\u5b9a\u3001\u5b89\u5168\u7684 web \u5e94\u7528\uff0c\u5e76\u4e14 code \u89c4\u8303\u4e00\u81f4\uff0c\u6613\u4e8e\u7ef4\u62a4\u3002 thinkphp \u6846\u67b6\u5b8c\u5168\u9075\u5faa mvc \u67b6\u6784\uff0c\u5177\u6709\u5fae\u5185\u6838\u548c\u63d2\u4ef6\u4fee\u6539\u7b49\u591a\u79cd\u6269\u5c55\u65b9\u5f0f\uff0c\u8ba9\u7f16\u5199 web \u5e94\u7528\u53d8\u5f97\u8f7b\u677e\u548c\u4fbf\u6377\u3002<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u5b66\u4f1a\u5982\u4f55\u7528 ThinkPHP \u65b0\u5efa\u9879\u76ee\uff0c\u4e0b\u9762\u5c31\u8ddf\u968f\u7b14\u8005\u7684\u6b65\u9aa4\u4e00\u8d77\u6765\u5b66\u4e60\u5427\u3002<\/p>\n<p>\u51c6\u5907\u5de5\u4f5c<\/p>\n<p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fdd\u4ee5\u4e0b\u6761\u4ef6\u90fd\u5df2\u7ecf\u6ee1\u8db3\uff1a<\/p>\n<ol>\n<li>PHP 5.3.0 \u6216\u66f4\u9ad8\u7248\u672c\uff0c\u4e14\u5f00\u542f\u4e86 PDO \u6269\u5c55\u3001CURL \u6269\u5c55\u548c OpenSSL \u6269\u5c55\u3002<\/li>\n<li>MySQL 5.0 \u6216\u66f4\u9ad8\u7248\u672c\u3002<\/li>\n<li>\u4e00\u4e2a\u96c6\u6210\u73af\u5883\uff08\u5982 XAMPP \u6216 WAMP\uff09\u6216\u8005\u4f7f\u7528 PHP Built-in Web Server\u3002<\/li>\n<\/ol>\n<p>\u5b89\u88c5 ThinkPHP \u6846\u67b6<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li>\u9996\u5148\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684 ThinkPHP \u6846\u67b6\uff0c\u4f60\u53ef\u4ee5\u5728\u5b98\u65b9\u7f51\u7ad9\u4e0a\u4e0b\u8f7d\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 Composer \u5b89\u88c5\u3002<\/li>\n<li>\u4e0b\u8f7d\u5b8c\u6210\u4e4b\u540e\uff0c\u5c06\u538b\u7f29\u5305\u89e3\u538b\u5230\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u3002<\/li>\n<li>\u6253\u5f00\u9879\u76ee\u7684\u6839\u76ee\u5f55\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u540d\u5b57\u4e3a public \u7684\u6587\u4ef6\u5939\u3002\u5c06 public \u6587\u4ef6\u5939\u4f5c\u4e3a\u4f60\u7684\u7f51\u7ad9\u6839\u76ee\u5f55\uff0c\u8fd9\u6837\u7528\u6237\u624d\u80fd\u8bbf\u95ee\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<\/ol>\n<p>Create your first ThinkPHP project<\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u662f\u521b\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a ThinkPHP \u9879\u76ee\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a hello \u76ee\u5f55\uff0c\u4f5c\u4e3a\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<li>\u8fdb\u5165 hello \u76ee\u5f55\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a index.html \u7684\u6587\u4ef6\uff0c\u5e76\u5199\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/li>\n<\/ol>\n<pre>\n\n\n    &lt;title&gt;Hello ThinkPHP!&lt;\/title&gt;&lt;h1&gt;Hello ThinkPHP!&lt;\/h1&gt;\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u73b0\u5728\uff0c\u6211\u4eec\u9700\u8981\u4e3a hello \u5e94\u7528\u7a0b\u5e8f\u521b\u5efa\u4e00\u4e2a\u5165\u53e3\u6587\u4ef6\u3002\u5728 hello \u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a index.php \u6587\u4ef6\uff0c\u5e76\u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/li>\n<\/ol>\n<pre>&lt;?php namespace appindexcontroller;\n\nclass Index\n{\n    public function index()\n    {\n        return view();\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u73b0\u5728\uff0c\u6211\u4eec\u9700\u8981\u544a\u8bc9\u6846\u67b6\u5165\u53e3\u6587\u4ef6\u7684\u4f4d\u7f6e\u3002\u5728\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a index.php \u6587\u4ef6\uff0c\u5e76\u5199\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/li>\n<\/ol>\n<pre>&lt;?php \/\/ \u5e94\u7528\u5165\u53e3\u6587\u4ef6\ndefine('APP_PATH', __DIR__ . '\/..\/hello\/');\n\/\/ \u52a0\u8f7d\u6846\u67b6\u5f15\u5bfc\u6587\u4ef6\nrequire __DIR__ . '\/..\/thinkphp\/start.php';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ol>\n<li>\u8bbf\u95ee http:\/\/localhost\/hello\uff0c\u4f60\u5e94\u8be5\u5c06\u770b\u5230 &#8220;Hello ThinkPHP!&#8221; \u7684\u6587\u5b57\u3002<\/li>\n<\/ol>\n<p>\u81f3\u6b64\uff0c\u4f60\u5df2\u7ecf\u6210\u529f\u4f7f\u7528 ThinkPHP \u521b\u5efa\u4e86\u4f60\u7684\u7b2c\u4e00\u4e2a\u9879\u76ee\u3002<\/p>\n<p>\u7ed3\u8bba<\/p>\n<p>\u603b\u4e4b\uff0c\u4f7f\u7528 ThinkPHP \u521b\u5efa\u9879\u76ee\u975e\u5e38\u5bb9\u6613\uff0c\u53ea\u9700\u9075\u5faa\u4e0a\u8ff0\u6b65\u9aa4\u5373\u53ef\u5feb\u901f\u4e0a\u624b\u3002ThinkPHP \u63d0\u4f9b\u4e86\u8bb8\u591a\u5de5\u5177\u548c\u7ec4\u4ef6\uff0c\u4f7f\u5f97\u5f00\u53d1\u53d8\u5f97\u8f7b\u677e\uff0c\u8ba9\u6211\u4eec\u80fd\u591f\u66f4\u5feb\u5730\u6784\u5efa\u9ad8\u6548\u3001\u7a33\u5b9a\u3001\u5b89\u5168\u3001\u6613\u4e8e\u7ef4\u62a4\u7684 Web \u5e94\u7528\u7a0b\u5e8f\uff0c\u5e2e\u52a9\u6211\u4eec\u66f4\u5feb\u5730\u5b9e\u73b0\u6211\u4eec\u7684\u4e1a\u52a1\u9700\u6c42\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u7528thinkphp\u65b0\u5efa\u9879\u76ee\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>thinkphp \u662f\u4e00\u4e2a\u5f00\u6e90\u7684 php \u6846\u67b6\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7684\u7ec4\u4ef6\u548c\u5de5\u5177\uff0c\u5e2e\u52a9\u6211\u4eec\u5feb\u901f\u6784\u5efa\u9ad8\u6548\u3001\u7a33\u5b9a\u3001\u5b89\u5168\u7684 web \u5e94\u7528\uff0c\u5e76\u4e14 code \u89c4\u8303\u4e00\u81f4\uff0c\u6613\u4e8e\u7ef4\u62a4\u3002 thinkphp \u6846\u67b6\u5b8c\u5168\u9075\u5faa mvc \u67b6\u6784\uff0c\u5177\u6709\u5fae\u5185\u6838\u548c\u63d2\u4ef6\u4fee\u6539\u7b49\u591a\u79cd\u6269\u5c55\u65b9\u5f0f\uff0c\u8ba9\u7f16\u5199 web \u5e94\u7528\u53d8\u5f97\u8f7b\u677e\u548c\u4fbf\u6377\u3002 \u5982\u679c\u4f60\u60f3\u5b66\u4f1a\u5982\u4f55\u7528 ThinkPHP \u65b0\u5efa\u9879\u76ee\uff0c\u4e0b\u9762\u5c31\u8ddf\u968f\u7b14\u8005\u7684\u6b65\u9aa4\u4e00\u8d77\u6765\u5b66\u4e60\u5427\u3002 \u51c6\u5907\u5de5\u4f5c \u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fdd\u4ee5\u4e0b\u6761\u4ef6\u90fd\u5df2\u7ecf\u6ee1\u8db3\uff1a PHP 5.3.0 \u6216\u66f4\u9ad8\u7248\u672c\uff0c\u4e14\u5f00\u542f\u4e86 PDO \u6269\u5c55\u3001CURL \u6269\u5c55\u548c OpenSSL \u6269\u5c55\u3002 MySQL 5.0 \u6216\u66f4\u9ad8\u7248\u672c\u3002 \u4e00\u4e2a\u96c6\u6210\u73af\u5883\uff08\u5982 XAMPP \u6216 WAMP\uff09\u6216\u8005\u4f7f\u7528 PHP Built-in Web Server\u3002 \u5b89\u88c5 ThinkPHP \u6846\u67b6 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u9996\u5148\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684 ThinkPHP \u6846\u67b6\uff0c\u4f60\u53ef\u4ee5\u5728\u5b98\u65b9\u7f51\u7ad9\u4e0a\u4e0b\u8f7d\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 Composer \u5b89\u88c5\u3002 \u4e0b\u8f7d\u5b8c\u6210\u4e4b\u540e\uff0c\u5c06\u538b\u7f29\u5305\u89e3\u538b\u5230\u9879\u76ee\u7684\u6839\u76ee\u5f55\u4e0b\u3002 \u6253\u5f00\u9879\u76ee\u7684\u6839\u76ee\u5f55\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u540d\u5b57\u4e3a public \u7684\u6587\u4ef6\u5939\u3002\u5c06 public \u6587\u4ef6\u5939\u4f5c\u4e3a\u4f60\u7684\u7f51\u7ad9\u6839\u76ee\u5f55\uff0c\u8fd9\u6837\u7528\u6237\u624d\u80fd\u8bbf\u95ee\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u3002 Create your [&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-23093","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23093","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=23093"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23093\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=23093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=23093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=23093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}