{"id":23077,"date":"2024-11-21T10:45:57","date_gmt":"2024-11-21T02:45:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/23077\/"},"modified":"2024-11-21T10:45:57","modified_gmt":"2024-11-21T02:45:57","slug":"wamp%e7%8e%af%e5%a2%83%e5%ae%89%e8%a3%85thinkphp","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/23077\/","title":{"rendered":"wamp\u73af\u5883\u5b89\u88c5thinkphp"},"content":{"rendered":"<p>wamp\u73af\u5883\u5b89\u88c5thinkphp<\/p>\n<p>WAMP\uff08Windows + Apache + MySQL + PHP\uff09\u662f\u4e00\u79cd\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u642d\u5efaWeb\u5f00\u53d1\u73af\u5883\u7684\u96c6\u6210\u8f6f\u4ef6\u5305\u3002\u800cThinkPHP\u662f\u4e00\u4e2a\u57fa\u4e8ePHP\u7684Web\u5e94\u7528\u5f00\u53d1\u6846\u67b6\u3002\u5728Windows\u73af\u5883\u4e2d\u5f00\u53d1Web\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u4f7f\u7528WAMP\u548cThinkPHP\u6765\u5b8c\u6210\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728Windows\u7cfb\u7edf\u4e0b\u5b89\u88c5WAMP\u73af\u5883\uff0c\u5e76\u4f7f\u7528ThinkPHP\u6846\u67b6\u8fdb\u884cWeb\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u3002<\/p>\n<p>\u4e00\u3001WAMP\u73af\u5883\u5b89\u88c5<\/p>\n<p>1.\u4e0b\u8f7dWAMP<\/p>\n<p>\u5b98\u7f51\u5730\u5740\uff1ahttp:\/\/www.wampserver.com\/en\/<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p>\u4e0b\u8f7d\u5bf9\u5e94\u7684\u7248\u672c\uff0c\u6839\u636e\u81ea\u5df1\u7535\u8111\u64cd\u4f5c\u7cfb\u7edf\u7684\u4f4d\u6570\u6765\u9009\u62e9x86\u6216x64\u7248\u672c\u7684WAMP\u5b89\u88c5\u5305\u3002<\/p>\n<p>2.\u5b89\u88c5WAMP<\/p>\n<p>\u53cc\u51fb\u4e0b\u8f7d\u7684WAMP\u5b89\u88c5\u5305\uff0c\u6309\u7167\u63d0\u793a\u5b89\u88c5\u5373\u53ef\uff0c\u4e00\u822c\u4fdd\u6301\u9ed8\u8ba4\u914d\u7f6e\u5373\u53ef\u3002<\/p>\n<p>3.\u542f\u52a8WAMP<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f1a\u5728Windows\u7cfb\u7edf\u6258\u76d8\u4e2d\u51fa\u73b0WAMP\u7684\u56fe\u6807\uff0c\u53cc\u51fb\u6253\u5f00\u540e\uff0c\u53ef\u4ee5\u770b\u5230WAMP\u670d\u52a1\u5668\u5df2\u7ecf\u542f\u52a8\u3002<\/p>\n<p>\u4e8c\u3001ThinkPHP\u6846\u67b6\u5b89\u88c5<\/p>\n<p>1.\u4e0b\u8f7dThinkPHP\u6846\u67b6<\/p>\n<p>\u5b98\u7f51\u5730\u5740\uff1ahttp:\/\/www.thinkphp.cn\/<\/p>\n<p>\u5728\u9996\u9875\u4e0a\u65b9\u7684\u201c\u4e0b\u8f7d\u201d\u9009\u9879\u5361\u4e2d\u627e\u5230\u201cThinkPHP5.X\uff08LTS\uff09\u201d\u5e76\u4e0b\u8f7d\u3002<\/p>\n<p>2.\u914d\u7f6eThinkPHP<\/p>\n<p>\u5c06\u4e0b\u8f7d\u4e0b\u6765\u7684\u538b\u7f29\u6587\u4ef6\u89e3\u538b\u7f29\u5230WAMP\u670d\u52a1\u5668\u9ed8\u8ba4\u7684Web\u6839\u76ee\u5f55\u4e0b\uff08\u9ed8\u8ba4\u4e3aC:wampwww\uff09\uff0c\u5f97\u5230\u5982\u4e0b\u76ee\u5f55\u7ed3\u6784\uff1a<\/p>\n<pre>www\n\u2502   favicon.ico\n\u2502   index.php\n\u2502\n\u2514\u2500\u2500\u2500thinkphp\n\u2502   \u2502   ...<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0cthinkphp\u6587\u4ef6\u5939\u662fThinkPHP\u6846\u67b6\u7684\u6838\u5fc3\u6587\u4ef6\u3002<\/p>\n<p>\u63a5\u7740\uff0c\u4fee\u6539WAMP\u7684Apache\u914d\u7f6e\u6587\u4ef6\uff08httpd.conf\uff09\u3002<\/p>\n<p>\u627e\u5230 DocumentRoot \u548c Directory \u6807\u7b7e\uff0c\u5c06\u4e24\u8005\u6307\u5411\u521a\u624d\u89e3\u538b\u7f29\u7684\u76ee\u5f55\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>DocumentRoot \"C:\/wamp\/www\"\n&lt;directory&gt;&lt;\/directory&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6ce8\u610f\u5c06\u8def\u5f84\u6539\u4e3a\u81ea\u5df1\u89e3\u538b\u7f29\u7684\u76ee\u5f55\u8def\u5f84\u3002<\/p>\n<p>\u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58httpd.conf\u6587\u4ef6\u5e76\u91cd\u542fApache\u670d\u52a1\uff0c\u4f7f\u914d\u7f6e\u751f\u6548\u3002<\/p>\n<p>\u4e09\u3001\u521b\u5efa\u5e76\u8fd0\u884c\u7b2c\u4e00\u4e2aThinkPHP\u7a0b\u5e8f<\/p>\n<p>1.\u65b0\u5efa\u4e00\u4e2a\u9879\u76ee<\/p>\n<p>\u5728WAMP\u7684Web\u6839\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\u4f5c\u4e3a\u6211\u4eec\u7684\u9879\u76ee\uff0c\u4f8b\u5982 myproject\u3002<\/p>\n<p>2.\u521b\u5efa\u9879\u76ee\u6587\u4ef6\u7ed3\u6784<\/p>\n<p>\u5728\u8be5\u6587\u4ef6\u5939\u4e0b\u65b0\u5efa\u5982\u4e0b\u76ee\u5f55\u7ed3\u6784\uff1a<\/p>\n<pre>www\n\u2502   favicon.ico\n\u2502   index.php\n\u2502\n\u2514\u2500\u2500\u2500myproject\n\u2502   \u2514\u2500\u2500\u2500application\n\u2502   \u2502   \u2514\u2500\u2500\u2500index\n\u2502   \u2502   \u2502   \u2514\u2500\u2500\u2500controller\n\u2502   \u2502   \u2502   \u2502   Index.php\n\u2502   \u2502   \u2502   \u2514\u2500\u2500\u2500view\n\u2502   \u2502   \u2502   \u2514\u2500\u2500\u2500config.php\n\u2502   \u2502   \u2502\n\u2502   \u2502   \u2514\u2500\u2500\u2500config\n\u2502   \u2502   \u2502   config.php\n\u2502   \u2502   \u2502\n\u2502   \u2502   \u2514\u2500\u2500\u2500 ...\n\u2502   \u2502\n\u2502   \u251c\u2500public\n\u2502   \u2502  \u251c\u2500index.php\n\u2502   \u2502  \u2514\u2500logo.png\n\u2502   \u2502\n\u2502   \u251c\u2500thinkphp\n\u2502   \u2502  \u2514\u2500 ...<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0capplication\u6587\u4ef6\u5939\u662f\u5e94\u7528\u76ee\u5f55\uff0cindex\u662f\u5e94\u7528\u540d\uff0ccontroller\u662f\u63a7\u5236\u5668\u76ee\u5f55\uff0cIndex.php\u662f\u63a7\u5236\u5668\u6587\u4ef6\uff0cview\u662f\u89c6\u56fe\u76ee\u5f55\uff0cconfig.php\u662f\u914d\u7f6e\u6587\u4ef6\uff1bconfig\u6587\u4ef6\u5939\u4e2d\u5305\u542b\u4e86\u914d\u7f6e\u6587\u4ef6\u3002public\u662f\u516c\u5171\u6587\u4ef6\u76ee\u5f55\uff0c\u91cc\u9762\u53ea\u6709\u4e00\u4e2a\u5165\u53e3\u6587\u4ef6index.php\u3002thinkphp\u662fThinkPHP\u6846\u67b6\u6838\u5fc3\u6587\u4ef6\u3002<\/p>\n<p>3.\u7f16\u5199\u63a7\u5236\u5668\u4ee3\u7801<\/p>\n<p>\u5728Controller\u76ee\u5f55\u4e0b\u65b0\u5efaIndex.php\u6587\u4ef6\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>&lt;?php namespace appindexcontroller;\nuse thinkController;\nclass Index extends Controller\n{\n    public function index()\n    {\n        return 'Hello, ThinkPHP5!';\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d namespace \u5b9a\u4e49\u4e86\u8be5\u63a7\u5236\u5668\u6240\u5728\u7684\u547d\u540d\u7a7a\u95f4\uff1buse\u5f15\u5165\u4e86\u63a7\u5236\u5668\u9700\u8981\u7684\u7c7b\u5e93\uff0c\u5e76\u7ee7\u627f\u4e86thinkController\u7c7b\uff1bindex\u65b9\u6cd5\u4e3a\u63a7\u5236\u5668\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u8fd4\u56de\u4efb\u610f\u5b57\u7b26\u4e32\u3002<\/p>\n<p>4.\u8fd0\u884c\u7a0b\u5e8f<\/p>\n<p>\u6253\u5f00\u6d4f\u89c8\u5668\u5e76\u8bbf\u95eehttp:\/\/localhost\/myproject\/public\/index.php\/index\/index\uff0c\u5373\u53ef\u770b\u5230\u7a0b\u5e8f\u8fd4\u56de\u7684\u5b57\u7b26\u4e32 &#8220;Hello, ThinkPHP5!&#8221;\u3002<\/p>\n<p>\u81f3\u6b64\uff0c\u4e00\u4e2a\u57fa\u4e8eWAMP\u73af\u5883\u548cThinkPHP\u6846\u67b6\u7684Web\u5e94\u7528\u7a0b\u5e8f\u5df2\u7ecf\u6210\u529f\u8fd0\u884c\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u5728Windows\u7cfb\u7edf\u4e0b\u5b89\u88c5WAMP\u73af\u5883\u548cThinkPHP\u6846\u67b6\uff0c\u5e76\u6f14\u793a\u4e86\u5982\u4f55\u521b\u5efa\u548c\u8fd0\u884c\u4e00\u4e2a\u6700\u7b80\u5355\u7684Web\u5e94\u7528\u7a0b\u5e8f\u3002\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\u53ef\u4ee5\u6781\u5927\u5730\u63d0\u9ad8Web\u5f00\u53d1\u6548\u7387\uff0c\u800c\u4f7f\u7528\u6846\u67b6\u5219\u53ef\u4ee5\u8ba9\u7a0b\u5e8f\u66f4\u52a0\u89c4\u8303\u5316\uff0c\u6613\u4e8e\u7ef4\u62a4\u548c\u5347\u7ea7\u3002\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fwamp\u73af\u5883\u5b89\u88c5thinkphp\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>wamp\u73af\u5883\u5b89\u88c5thinkphp WAMP\uff08Windows + Apache + MySQL + PHP\uff09\u662f\u4e00\u79cd\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u642d\u5efaWeb\u5f00\u53d1\u73af\u5883\u7684\u96c6\u6210\u8f6f\u4ef6\u5305\u3002\u800cThinkPHP\u662f\u4e00\u4e2a\u57fa\u4e8ePHP\u7684Web\u5e94\u7528\u5f00\u53d1\u6846\u67b6\u3002\u5728Windows\u73af\u5883\u4e2d\u5f00\u53d1Web\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u4f7f\u7528WAMP\u548cThinkPHP\u6765\u5b8c\u6210\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u5982\u4f55\u5728Windows\u7cfb\u7edf\u4e0b\u5b89\u88c5WAMP\u73af\u5883\uff0c\u5e76\u4f7f\u7528ThinkPHP\u6846\u67b6\u8fdb\u884cWeb\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u53d1\u3002 \u4e00\u3001WAMP\u73af\u5883\u5b89\u88c5 1.\u4e0b\u8f7dWAMP \u5b98\u7f51\u5730\u5740\uff1ahttp:\/\/www.wampserver.com\/en\/ \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4e0b\u8f7d\u5bf9\u5e94\u7684\u7248\u672c\uff0c\u6839\u636e\u81ea\u5df1\u7535\u8111\u64cd\u4f5c\u7cfb\u7edf\u7684\u4f4d\u6570\u6765\u9009\u62e9x86\u6216x64\u7248\u672c\u7684WAMP\u5b89\u88c5\u5305\u3002 2.\u5b89\u88c5WAMP \u53cc\u51fb\u4e0b\u8f7d\u7684WAMP\u5b89\u88c5\u5305\uff0c\u6309\u7167\u63d0\u793a\u5b89\u88c5\u5373\u53ef\uff0c\u4e00\u822c\u4fdd\u6301\u9ed8\u8ba4\u914d\u7f6e\u5373\u53ef\u3002 3.\u542f\u52a8WAMP \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f1a\u5728Windows\u7cfb\u7edf\u6258\u76d8\u4e2d\u51fa\u73b0WAMP\u7684\u56fe\u6807\uff0c\u53cc\u51fb\u6253\u5f00\u540e\uff0c\u53ef\u4ee5\u770b\u5230WAMP\u670d\u52a1\u5668\u5df2\u7ecf\u542f\u52a8\u3002 \u4e8c\u3001ThinkPHP\u6846\u67b6\u5b89\u88c5 1.\u4e0b\u8f7dThinkPHP\u6846\u67b6 \u5b98\u7f51\u5730\u5740\uff1ahttp:\/\/www.thinkphp.cn\/ \u5728\u9996\u9875\u4e0a\u65b9\u7684\u201c\u4e0b\u8f7d\u201d\u9009\u9879\u5361\u4e2d\u627e\u5230\u201cThinkPHP5.X\uff08LTS\uff09\u201d\u5e76\u4e0b\u8f7d\u3002 2.\u914d\u7f6eThinkPHP \u5c06\u4e0b\u8f7d\u4e0b\u6765\u7684\u538b\u7f29\u6587\u4ef6\u89e3\u538b\u7f29\u5230WAMP\u670d\u52a1\u5668\u9ed8\u8ba4\u7684Web\u6839\u76ee\u5f55\u4e0b\uff08\u9ed8\u8ba4\u4e3aC:wampwww\uff09\uff0c\u5f97\u5230\u5982\u4e0b\u76ee\u5f55\u7ed3\u6784\uff1a www \u2502 favicon.ico \u2502 index.php \u2502 \u2514\u2500\u2500\u2500thinkphp \u2502 \u2502 &#8230; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0cthinkphp\u6587\u4ef6\u5939\u662fThinkPHP\u6846\u67b6\u7684\u6838\u5fc3\u6587\u4ef6\u3002 \u63a5\u7740\uff0c\u4fee\u6539WAMP\u7684Apache\u914d\u7f6e\u6587\u4ef6\uff08httpd.conf\uff09\u3002 \u627e\u5230 DocumentRoot \u548c Directory \u6807\u7b7e\uff0c\u5c06\u4e24\u8005\u6307\u5411\u521a\u624d\u89e3\u538b\u7f29\u7684\u76ee\u5f55\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a DocumentRoot &#8220;C:\/wamp\/www&#8221; &lt;directory&gt;&lt;\/directory&gt; \u767b\u5f55\u540e\u590d\u5236 \u6ce8\u610f\u5c06\u8def\u5f84\u6539\u4e3a\u81ea\u5df1\u89e3\u538b\u7f29\u7684\u76ee\u5f55\u8def\u5f84\u3002 \u4fee\u6539\u5b8c\u6210\u540e\uff0c\u4fdd\u5b58httpd.conf\u6587\u4ef6\u5e76\u91cd\u542fApache\u670d\u52a1\uff0c\u4f7f\u914d\u7f6e\u751f\u6548\u3002 \u4e09\u3001\u521b\u5efa\u5e76\u8fd0\u884c\u7b2c\u4e00\u4e2aThinkPHP\u7a0b\u5e8f 1.\u65b0\u5efa\u4e00\u4e2a\u9879\u76ee \u5728WAMP\u7684Web\u6839\u76ee\u5f55\u4e0b\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\u4f5c\u4e3a\u6211\u4eec\u7684\u9879\u76ee\uff0c\u4f8b\u5982 myproject\u3002 2.\u521b\u5efa\u9879\u76ee\u6587\u4ef6\u7ed3\u6784 \u5728\u8be5\u6587\u4ef6\u5939\u4e0b\u65b0\u5efa\u5982\u4e0b\u76ee\u5f55\u7ed3\u6784\uff1a www \u2502 [&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-23077","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23077","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=23077"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/23077\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=23077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=23077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=23077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}