{"id":2322,"date":"2023-08-08T18:39:19","date_gmt":"2023-08-08T10:39:19","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=2322"},"modified":"2023-08-08T18:39:19","modified_gmt":"2023-08-08T10:39:19","slug":"php%e7%bd%91%e7%ab%99%e6%89%93%e5%8c%85%e7%94%9f%e6%88%90app%e5%90%97%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/2322\/","title":{"rendered":"php\u7f51\u7ad9\u6253\u5305\u751f\u6210app\u5417\uff1f"},"content":{"rendered":"

\u5728\u8fd9\u4e2a\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u5982\u4f55\u5c06 PHP \u7f51\u7ad9\u6253\u5305\u751f\u6210\u79fb\u52a8\u5e94\u7528(APP)\u3002\u5c3d\u7ba1 PHP \u662f\u4e00\u79cd\u670d\u52a1\u5668\u7aef\u7684\u811a\u672c\u8bed\u8a00\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 Webview \u548c Apache Cordova \u7b49\u5de5\u5177\u5c06\u5b83\u8f6c\u6362\u4e3a\u539f\u751f\u5e94\u7528\u3002\u663e\u800c\u6613\u89c1\uff0c\u8fd9\u4e0d\u662f\u5c06\u6574\u4e2a PHP \u4ee3\u7801\u76f4\u63a5\u8f6c\u6362\u4e3a\u539f\u751f\u5e94\u7528\uff0c\u800c\u662f\u5c06\u73b0\u6709\u7684 PHP \u7f51\u7ad9\u5c01\u88c5\u4e3a\u4e00\u4e2a\u5d4c\u5165\u5f0f\u7684 Webview\uff0c\u4ece\u800c\u53ef\u4ee5\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\u8bbf\u95ee\u5b83\u3002<\/p>\n

\u8bf7\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\u5c06\u60a8\u7684 PHP \u7f51\u7ad9\u6253\u5305\u751f\u6210 APP\uff1a<\/p>\n

1. \u5c06 PHP \u7f51\u7ad9\u8f6c\u79fb\u5230\u670d\u52a1\u5668<\/p>\n

\u9996\u5148\uff0c\u60a8\u9700\u8981\u786e\u4fdd\u60a8\u7684 PHP \u7f51\u7ad9\u6258\u7ba1\u5728\u80fd\u591f\u8ba9\u79fb\u52a8\u8bbe\u5907\u8bbf\u95ee\u7684\u670d\u52a1\u5668\u4e0a\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u5404\u79cd Web \u6258\u7ba1\u670d\u52a1\u624b\u673a\u7f51\u7ad9app\u751f\u6210<\/a>\uff0c\u5982 GoDaddy\u3001Namecheap \u6216 Bluehost\u3002<\/p>\n

2. \u5b89\u88c5\u4e0e\u8bbe\u7f6e Apache Cordova<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u60a8\u9700\u8981\u5b89\u88c5 Apache Cordova\uff0c\u5b83\u662f\u4e00\u6b3e\u7528\u4e8e\u521b\u5efa\u539f\u751f\u79fb\u52a8\u5e94\u7528\u7684\u5f00\u6e90\u5e73\u53f0\u3002\u8fd9\u4e9b\u5e94\u7528\u7a0b\u5e8f\u5177\u6709\u8de8\u5e73\u53f0\u7279\u6027\uff0c\u53ef\u4ee5\u4e0e WebView \u8fdb\u884c\u4ea4\u4e92\u3002\u786e\u4fdd\u60a8\u5df2\u5b89\u88c5\u4e86 Node.js\uff08https:\/\/nodejs.org\/en\/\uff09\uff0c\u7136\u540e\u901a\u8fc7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 Cordova\uff1a<\/p>\n

“`bash<\/p>\n

npm install -g cordova<\/p>\n

“`<\/p>\n

\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Cordova \u9879\u76ee\uff1a<\/p>\n

“`bash<\/p>\n

cordova create your_project_folder com.example.yourapp YourAppName<\/p>\n

“`<\/p>\n

\u7136\u540e\uff0c\u8fdb\u5165\u60a8\u521a\u521a\u521b\u5efa\u7684\u9879\u76ee\u6587\u4ef6\u5939\uff1a<\/p>\n

“`bash<\/p>\n

cd your_project_folder<\/p>\n

“`<\/p>\n

\u73b0\u5728\uff0c\u5c06\u9700\u8981\u7684\u5e73\u53f0\u6dfb\u52a0\u5230 Cordova \u9879\u76ee\u4e2d\u3002\u4f8b\u5982\uff0c\u8981\u6dfb\u52a0 iOS \u548c Android \u5e73\u53f0\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`bash<\/p>\n

cordova platform add ios<\/p>\n

cordova platform add android<\/p>\n

“`<\/p>\n

3. \u914d\u7f6eWebView<\/p>\n

\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u8bbe\u7f6e WebView\uff0c\u4ee5\u4fbf\u5b83\u53ef\u4ee5\u52a0\u8f7d\u5e76\u663e\u793a\u60a8\u7684 PHP \u7f51\u7ad9\u3002\u5728 `your_project_folder\/www` \u6587\u4ef6\u5939\u4e2d\uff0c\u60a8\u4f1a\u627e\u5230\u4e00\u4e2a\u540d\u4e3a `index\u5728\u7ebfapp\u5236\u4f5c\u8f6f\u4ef6\u4e00\u952e\u751f\u6210<\/a>.html` \u7684\u6587\u4ef6\u3002\u8fd9\u662f Cordova \u9879\u76ee\u7684\u4e3b\u6587\u4ef6\u3002<\/p>\n

\u6253\u5f00\u6b64\u6587\u4ef6\u5e76\u7528\u4ee5\u4e0b\u4ee3\u7801\u66ff\u6362\u73b0\u6709\u5185\u5bb9\uff1a<\/p>\n

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

\n

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

YourAppName<\/title><\/p>\n<\/p>\n<p>\n<p>\n<\/p>\n<\/p>\n<p>“`<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4fee\u6539 `https:\/\/your_php_website_url` \u4e3a\u60a8\u6258\u7ba1\u7684 PHP \u7f51\u7ad9\u7684\u5b9e\u9645 URL\u3002<\/p>\n<p>4. \u7f16\u8bd1\u4e0e\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u73b0\u5728\u53ef\u4ee5\u7f16\u8bd1\u5e76\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\u4e86\u3002\u8981\u7f16\u8bd1 Android\uff08\u786e\u4fdd\u5df2\u5b89\u88c5 Android Studio\uff09\u548c iOS\uff08\u786e\u4fdd\u5728 macOS \u4e0a\u5b89\u88c5\u4e86 Xcode\uff09 \u5e94\u7528\uff0c\u8bf7\u5206\u522b\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<p>“`bash<\/p>\n<p>cordova build android<\/p>\n<p>cordova build ios<\/p>\n<p>“`<\/p>\n<p>\u4e3a\u4e86\u5728\u6a21\u62df\u5668\u6216\u5b9e\u9645\u8bbe\u5907\u4e0a\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff0c\u8bf7\u6267\u884c\uff1a<\/p>\n<p>“`bash<\/p>\n<p>cordova run android<\/p>\n<p>cordova run ios<\/p>\n<p>“`<\/p>\n<p>\u73b0\u5728\uff0c\u60a8\u7684 PHP \u7f51\u7ad9\u5df2\u7ecf\u6210\u529f\u6253\u5305\u6210\u4e86\u4e00\u4e2a\u539f\u751f\u79fb\u52a8\u5e94\u7528\u3002\u4f46\u662f\uff0c\u8bf7\u6ce8\u610f\u7531\u4e8e\u8fd9\u4e2a\u65b9\u6cd5\u4f9d\u8d56 WebView\uff0c\u53ef\u80fd\u65e0\u6cd5\u63d0\u4f9b\u4e0e\u5b8c\u5168\u539f\u751f\u5e94\u7528\u76f8\u540c\u7684\u6027\u80fd\u3002\u53e6\u5916\uff0c\u60a8<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.yimenyun.net\/2023-01\/06\/16\/14860191011.jpg\" \/><\/figure>\n<\/p>\n<p>\u8fd8\u9700\u8981\u9488\u5bf9\u79fb\u52a8\u8bbe\u5907\u4f18\u5316\u60a8\u7684 PHP \u7f51\u7ad9\uff0c\u4ee5\u4fbf\u4e3a\u7528\u6237\u63d0\u4f9b\u66f4\u597d\u7684\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u8fd9\u4e2a\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u5982\u4f55\u5c06 PHP \u7f51\u7ad9\u6253\u5305\u751f\u6210\u79fb\u52a8\u5e94\u7528(APP)\u3002\u5c3d\u7ba1 PHP \u662f\u4e00\u79cd\u670d\u52a1\u5668\u7aef\u7684\u811a\u672c\u8bed\u8a00\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 Webview \u548c Apache Cordova \u7b49\u5de5\u5177\u5c06\u5b83\u8f6c\u6362\u4e3a\u539f\u751f<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[4875,4876,12,105,247],"topic":[],"class_list":["post-2322","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-phpapp","tag-app","tag-12","tag-105","tag-247"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/2322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=2322"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/2322\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=2322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=2322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=2322"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=2322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}