{"id":11574,"date":"2023-08-08T18:39:14","date_gmt":"2023-08-08T10:39:14","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/?p=11574"},"modified":"2023-08-08T18:39:14","modified_gmt":"2023-08-08T10:39:14","slug":"php%e6%ba%90%e7%a0%81%e7%94%a8%e4%bb%80%e4%b9%88%e8%bd%af%e4%bb%b6%e7%94%9f%e6%88%90app%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/appshangjia\/11574.html","title":{"rendered":"php\u6e90\u7801\u7528\u4ec0\u4e48\u8f6f\u4ef6\u751f\u6210app\uff1f"},"content":{"rendered":"<p>\u5c06PHP\u6e90\u7801\u8f6c\u6362\u6210APP\u7684\u89e3\u51b3\u65b9\u6848\u662f\u5c06PHP\u5e94\u7528\u7a0b\u5e8f\u4e0e\u5185\u7f6eWeb\u670d\u52a1\u5668\u548c\u6d4f\u89c8\u5668\u7ec4\u4ef6\u4e00\u8d77\u6253\u5305\u3002\u8fd9\u6837\uff0c\u7528\u6237\u53ef\u4ee5\u50cf\u4f7f\u7528\u5e38\u89c4\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\u8fd0\u884c\u4f60\u7684PHP\u5e94\u7528\u3002\u4ee5\u4e0b\u662f\u4e24\u79cd\u6d41\u884c\u7684\u65b9\u6cd5\uff0c\u5206\u522b\u662f\u4f7f\u7528PHP\u684c\u9762\u5de5\u5177\u548cNW.js\u3002<\/p>\n<p>1. \u4f7f\u7528PHP\u684c\u9762\u5de5\u5177\uff08\u5982 ExeOutput for PHP\uff0cPHP Desktop\uff09\uff1a<\/p>\n<p>   \u8fd9\u7c7b\u5de5<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-01\/06\/14\/25718932078.jpg\" \/><\/figure>\n<\/p>\n<p>\u5177\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5c06PHP\u6e90\u7801\u6253\u5305\u6210Windows\u6216\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\u7684\u684c\u9762\u5e94\u7528\u3002<\/p>\n<p>   \u4ee5ExeOutput for PHP\u4e3a\u4f8b\uff0c\u5b83\u7684\u57fa\u672c\u539f\u7406\u662f\u5c06\u4f60\u7684PHP\u6e90\u7801\u3001\u5185\u7f6e\u7684PHP\u8fd0\u884c\u65f6\u73af\u5883\u3001Web\u670d\u52a1\u5668\uff08\u4f8b\u5982Apache\u6216Nginx\uff09\u548cWeb\u6d4f\u89c8\u5668\u7ec4\u4ef6\uff08\u4f8b\u5982Chromium\uff09\u4e00\u8d77\u6253\u5305\u3002\u7528\u6237\u53ea\u9700\u8981\u8fd0\u884c\u751f\u6210\u7684.exe\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u5728\u672c\u5730\u73af\u5883\u4e2d\u4f7f\u7528\u4f60\u7684PHP\u5e94\u7528\u3002<\/p>\n<p>   \u5177\u4f53\u64cd\u4f5c\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>   1. \u4e0b\u8f7d\u5e76\u5b89\u88c5ExeOutput for PHP\u3002<\/p>\n<p>   2. \u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff0c\u5e76\u5c06\u4f60\u7684PHP\u6e90\u7801\u6dfb\u52a0\u5230\u9879\u76ee\u4e2d\u3002<\/p>\n<p>   3. \u914d\u7f6e\u9879\u76ee\u8bbe\u7f6e\uff0c\u4f8b\u5982\u7f51\u7ad9\u9996\u9875\u3001\u7a97\u53e3\u5927\u5c0f\u3001\u5e94\u7528\u56fe\u6807\u7b49\u3002<\/p>\n<p>   4. \u70b9\u51fb\u7f16\u8bd1\u6309\u94ae\uff0c\u751f\u6210.exe\u6587\u4ef6\u3002<\/p>\n<p>2. \u4f7f\u7528NW.js \u6253\u5305PHP\u5e94\u7528\uff1a<\/p>\n<p>   NW.js\u662f\u4e00\u79cd\u5f00\u53d1\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7684\u6280\u672f\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u4f7f\u7528HTML, CSS, JavaScript\u7b49Web\u6280\u672f\u7f16\u5199GUI\u5e94\u7528\u3002\u4e3a\u4e86\u5c06PHP\u6e90\u7801\u6253\u5305\u6210APP\uff0c\u6211\u4eec\u9700\u8981\u914d\u7f6eNW.js\u73af\u5883\uff0c\u4ee5\u4fbf\u4e0e\u5185\u7f6e\u7684Web\u670d\u52a1\u5668\u4e00\u8d77\u5de5\u4f5c\u3002<\/p>\n<p>   \u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<p>   1. \u4e0b\u8f7d\u5e76\u5b89\u88c5NW.js\u3002<\/p>\n<p>   2. \u5728\u4f60\u7684PHP\u9879\u76ee\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;package<a href=\"http:\/\/www.yimenyun.cn\/app-shengcheng-gongju-147.html\">\u600e\u4e48\u7ed9app\u4e0b\u8f7d\u751f\u6210\u7f51\u7ad9<\/a>.json&#8221;\u7684\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p>   &#8220;`<\/p>\n<p>   {<\/p>\n<p>       &#8220;name&#8221;: &#8220;your_app_name&#8221;,<\/p>\n<p>       &#8220;main&#8221;: &#8220;http:\/\/localhost:8000&#8221;,<\/p>\n<p>       &#8220;version&#8221;: &#8220;1.0.0&#8221;,<\/p>\n<p>       &#8220;window&#8221;: {<\/p>\n<p>           &#8220;title&#8221;: &#8220;Your App&#8221;,<\/p>\n<p>           &#8220;icon&#8221;: &#8220;icon.png&#8221;<\/p>\n<p>       },<\/p>\n<p>       &#8220;nodejs&#8221;: true<\/p>\n<p>   }<\/p>\n<p>   &#8220;`<\/p>\n<p>   3. \u5728PHP\u9879\u76ee\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;start.js&#8221;\u7684\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<p>   &#8220;`<\/p>\n<p>   const {spawn} = require(&#8216;child_process&#8217;);<\/p>\n<p>   const phpServer = spawn(&#8216;php&#8217;, [&#8216;-S&#8217;, &#8216;localhost:8000&#8217;]);<\/p>\n<p>   phpServer.stdout.on(&#8216;data&#8217;, data =&gt; {<\/p>\n<p>       console.log(`stdout: ${data}`);<\/p>\n<p>   });<\/p>\n<p>   phpServer.stderr.on(&#8216;data&#8217;, data =&gt; {<\/p>\n<p>       console.log(`stderr: ${data}`);<\/p>\n<p>   });<\/p>\n<p>   phpServer.on(&#8216;close&#8217;, <a href=\"http:\/\/www.yimenyun.cn\/zaixian-shengcheng-app-185.html\">\u5728\u7ebf\u751f\u6210app\u542f\u52a8\u56fe<\/a>code =&gt; {<\/p>\n<p>       console.log(`PHP server process exited with code ${code}`);<\/p>\n<p>   });<\/p>\n<p>   nw.Window.open(&#8216;package.json&#8217;, {}, function(win) {});<\/p>\n<p>   &#8220;`<\/p>\n<p>   4. \u8fd0\u884c\u547d\u4ee4 &#8220;nw .&#8221; (\u4e0d\u5e26\u5f15\u53f7)\u542f\u52a8\u5e94\u7528\u3002<\/p>\n<p>   5. \u4f7f\u7528NW.js\u7684\u547d\u4ee4\u884c\u5de5\u5177\u5c06\u9879\u76ee\u6253\u5305\u6210Windows, macOS\u6216Linux\u5e94\u7528\u3002<\/p>\n<p>\u8fd9\u4e24\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\u5c06PHP\u6e90\u7801\u8f6c\u6362\u4e3a\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f46\u8bf7\u6ce8\u610f\uff0c\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u901a\u5e38\u4e0d\u9002\u5408\u7528\u4f5c\u5927\u578bWeb\u5e94\u7528\u7a0b\u5e8f\u7684\u66ff\u4ee3\u65b9\u6848\u3002\u56e0\u6b64\uff0c\u5982\u679c\u4f60\u7684PHP\u9879\u76ee\u5305\u542b\u5927\u91cf\u7684\u590d\u6742\u529f\u80fd\u6216\u9700\u8981\u4e0e\u8fdc\u7a0b\u670d\u52a1\u5668\u8fdb\u884c\u5b9e\u65f6\u901a\u4fe1\uff0c\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u80fd\u4e0d\u662f\u6700\u4f73\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c06PHP\u6e90\u7801\u8f6c\u6362\u6210APP\u7684\u89e3\u51b3\u65b9\u6848\u662f\u5c06PHP\u5e94\u7528\u7a0b\u5e8f\u4e0e\u5185\u7f6eWeb\u670d\u52a1\u5668\u548c\u6d4f\u89c8\u5668\u7ec4\u4ef6\u4e00\u8d77\u6253\u5305\u3002\u8fd9\u6837\uff0c\u7528\u6237\u53ef\u4ee5\u50cf\u4f7f\u7528\u5e38\u89c4\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\u8fd0\u884c\u4f60\u7684PHP\u5e94\u7528\u3002\u4ee5\u4e0b\u662f\u4e24\u79cd\u6d41\u884c\u7684\u65b9\u6cd5\uff0c\u5206\u522b\u662f\u4f7f\u7528PHP\u684c\u9762\u5de5\u5177<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[17105,1775,3249,3031,1220],"class_list":{"0":"post-11574","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-appshangjia","7":"tag-app","8":"tag-1775","9":"tag-3249","11":"tag-1220"},"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/11574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=11574"}],"version-history":[{"count":0,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/11574\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=11574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=11574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=11574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}