{"id":9061,"date":"2023-11-14T15:44:48","date_gmt":"2023-11-14T07:44:48","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=9061"},"modified":"2023-11-14T15:44:48","modified_gmt":"2023-11-14T07:44:48","slug":"phpwindows10%e6%89%93%e5%8c%85%e6%9c%89%e5%93%aa%e4%ba%9b%e6%96%b9%e6%b3%95%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/11\/14\/phpwindows10%e6%89%93%e5%8c%85%e6%9c%89%e5%93%aa%e4%ba%9b%e6%96%b9%e6%b3%95%ef%bc%9f-2\/","title":{"rendered":"phpwindows10\u6253\u5305\u6709\u54ea\u4e9b\u65b9\u6cd5\uff1f"},"content":{"rendered":"

\u5728Windows 10\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u6253\u5305PHP\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06\u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72\u5230\u5176\u4ed6Windows\u673a\u5668\u4e0a\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u6253\u5305\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u3002<\/p>\n

1. \u539f\u7406<\/p>\n

\u5728Windows\u4e0a\u6253\u5305PHP\u5e94\u7528\u7a0b\u5e8f\uff0c\u9700\u8981\u5c06PHP\u89e3\u91ca\u5668\u548c\u5e94\u7528\u7a0b\u5e8f\u4e00\u8d77\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002\u8fd9\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u5305\u542b\u4e86\u6240\u6709\u9700\u8981\u7684\u4f9d\u8d56\u6587\u4ef6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u5176\u4ed6Windows\u673a\u5668\u4e0a\u8fd0\u884c\uff0c\u4e0d\u9700\u8981\u5b89\u88c5PHP\u89e3\u91ca\u5668\u548c\u5176\u4ed6\u4f9d\u8d56\u9879\u3002<\/p>\n

\u6253\u5305\u7684\u5173\u952e\u662f\u4f7f\u7528PHP\u7684\u5185\u7f6e\u6253\u5305\u5de5\u5177phar\u3002phar\u662fPHP\u7684\u4e00\u79cd\u6253\u5305\u683c\u5f0f\uff0c\u53ef\u4ee5\u5c06\u591a\u4e2a\u6587\u4ef6\u6253\u5305\u6210\u4e00\u4e2a\u6587\u4ef6\uff0c\u7c7b\u4f3c\u4e8ezip\u6587\u4ef6\u3002phar\u6587\u4ef6\u53ef\u4ee5\u76f4\u63a5\u5728PHP\u4e2d\u4f7f\u7528\uff0c\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u5728Windows\u4e0a\u8fd0\u884c\u3002<\/p>\n

2. \u6253\u5305\u6b65\u9aa4<\/p>\n

\u4e0b\u9762windows\u6253\u5305\u6587\u4ef6<\/a>\u662f\u5728Windows 10\u4e0a\u6253\u5305PHP\u5e94\u7528\u7a0b\u5e8f\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n

\u6b65\u9aa41\uff1a\u51c6\u5907\u5de5\u4f5c<\/p>\n

\u5728\u6253\u5305\u4e4b\u524d\uff0c\u9700\u8981\u5c06\u5e94\u7528\u7a0b\u5e8f\u653e\u5728\u4e00\u4e2a\u76ee\u5f55\u4e0b\uff0c\u5e76\u4e14\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u9879\u90fd\u5df2\u7ecf\u5b89\u88c5\u3002\u53e6\u5916\uff0c\u9700\u8981\u5b89\u88c5PHP\u89e3\u91ca\u5668\u548cphar\u6269\u5c55\u3002\u53ef\u4ee5\u5728php.ini\u6587\u4ef6\u591a\u4e2aexe\u6587\u4ef6\u7ed1\u6210\u4e00\u4e2aexe<\/a>\u4e2d\u5f00\u542fphar\u6269\u5c55\uff0c\u65b9\u6cd5\u662f\u53bb\u6389\u4ee5\u4e0b\u884c\u524d\u7684\u6ce8\u91ca\uff1a<\/p>\n

extension=php_phar.dll<\/p>\n

\u6b65\u9aa42\uff1a\u521b\u5efa\u6253\u5305\u811a\u672c<\/p>\n

\u5728\u5e94\u7528\u7a0b\u5e8f\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u6253\u5305\u811a\u672c\uff0c\u6587\u4ef6\u540d\u4e3abuild.php\u3002\u6253\u5305\u811a\u672c\u9700\u8981\u4f7f\u7528phar\u6269\u5c55\u7684API\uff0c\u5c06\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210phar\u6587\u4ef6\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6253\u5305\u811a\u672c\u793a\u4f8b\uff1a<\/p>\n

“`<\/p>\n<\/p>\n

$phar = new Phar(‘myapp.phar’);<\/p>\n

$p<\/p>\n

<\/figure>\n<\/p>\n

har->buildFromDirectory(__DIR__);<\/p>\n

$phar->setStub($phar->createDefaultStub(‘index.php’));<\/p>\n

“`<\/p>\n

\u8fd9\u4e2a\u811a\u672c\u5c06\u5e94\u7528\u7a0b\u5e8f\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u6253\u5305\u6210\u540d\u4e3amyapp.phar\u7684\u6587\u4ef6\uff0c\u5e76\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u9ed8\u8ba4\u7684\u5165\u53e3\u6587\u4ef6\u4e3aindex.php\u3002\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u4fee\u6539\u8fd9\u4e2a\u811a\u672c\u3002<\/p>\n

\u6b65\u9aa43\uff1a\u8fd0\u884c\u6253\u5305\u811a\u672c<\/p>\n

\u5728\u547d\u4ee4\u884c\u4e2d\u8fdb\u5165\u5e94\u7528\u7a0b\u5e8f\u76ee\u5f55\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

php build.php<\/p>\n

“`<\/p>\n

\u8fd9\u4e2a\u547d\u4ee4\u5c06\u6267\u884c\u6253\u5305\u811a\u672c\uff0c\u5e76\u751f\u6210myapp.phar\u6587\u4ef6\u3002<\/p>\n

\u6b65\u9aa44\uff1a\u6d4b\u8bd5\u6253\u5305\u6587\u4ef6<\/p>\n

\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6d4b\u8bd5\u6253\u5305\u6587\u4ef6\uff1a<\/p>\n

“`<\/p>\n

php myapp.phar<\/p>\n

“`<\/p>\n

\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u5e94\u7528\u7a0b\u5e8f\u5c06\u4f1a\u8fd0\u884c\u3002<\/p>\n

\u6b65\u9aa45\uff1a\u90e8\u7f72\u6253\u5305\u6587\u4ef6<\/p>\n

\u5c06myapp.phar\u6587\u4ef6\u590d\u5236\u5230\u5176\u4ed6Windows\u673a\u5668\u4e0a\uff0c\u76f4\u63a5\u8fd0\u884c\u8fd9\u4e2a\u6587\u4ef6\u5373\u53ef\u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

3. \u603b\u7ed3<\/p>\n

\u6253\u5305PHP\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06\u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72\u5230\u5176\u4ed6Windows\u673a\u5668\u4e0a\u3002\u4f7f\u7528phar\u6269\u5c55\u548c\u6253\u5305\u811a\u672c\uff0c\u53ef\u4ee5\u5c06\u5e94\u7528\u7a0b\u5e8f\u548cPHP\u89e3\u91ca\u5668\u6253\u5305\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u4e0d\u9700\u8981\u5b89\u88c5\u5176\u4ed6\u4f9d\u8d56\u9879\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u4fee\u6539\u6253\u5305\u811a\u672c\uff0c\u5b9e\u73b0\u66f4\u52a0\u590d\u6742\u7684\u6253\u5305\u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728Windows 10\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u6253\u5305PHP\u5e94\u7528\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06\u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72\u5230\u5176\u4ed6Windows\u673a\u5668\u4e0a\u3002\u672c\u6587\u5c06\u4ecb\u7ecd\u6253\u5305\u7684\u539f\u7406\u548c\u8be6\u7ec6\u6b65\u9aa4\u30021. \u539f\u7406\u5728Windows\u4e0a\u6253\u5305PHP\u5e94\u7528\u7a0b\u5e8f\uff0c\u9700\u8981\u5c06PHP\u89e3<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[15275,116,12,13912,2306],"topic":[],"class_list":["post-9061","post","type-post","status-publish","format-standard","hentry","category-zhuomianruanjian","tag-dmg","tag-116","tag-12","tag-exe","tag-2306"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/9061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=9061"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/9061\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=9061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=9061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=9061"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=9061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}