{"id":32072,"date":"2024-11-25T14:31:34","date_gmt":"2024-11-25T06:31:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/32072\/"},"modified":"2024-11-25T14:31:34","modified_gmt":"2024-11-25T06:31:34","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8wordpress%e4%b8%ad%e4%bd%bf%e7%94%a8laravel","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/32072\/","title":{"rendered":"\u5982\u4f55\u5728WordPress\u4e2d\u4f7f\u7528Laravel"},"content":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;<strong>wordpress\u6559\u7a0b<\/strong>\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u5982\u4f55\u5728 wordpress \u4e2d\u4f7f\u7528 \uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p style=\"z-index: 1\"><strong>Corcel \u8ba9\u4f60\u5728 WordPress \u4e2d\u4f7f\u7528 Laravel<\/strong><\/p>\n<blockquote><p>\n  \u4f60\u60f3\u8fc7\u53ef\u4ee5\u5728 WordPress \u4e2d\u4f7f\u7528 Laravel \u6216\u8005\u4efb\u610f\u4e00\u79cd PHP \u6846\u67b6\u5417\uff1f&nbsp;Corcel&nbsp;\u53ef\u4ee5\u5e2e\u4f60\u5b9e\u73b0\uff01\n<\/p><\/blockquote>\n<p>\u5f00\u53d1\u7f51\u7ad9\u5e94\u7528\u5c31\u5e94\u8be5\u662f\u5feb\u6377\u5e76\u6709\u8da3\u7684\u3002\u5f53\u7136\u4e86\uff0c\u6bcf\u4e2a\u5e94\u7528\u90fd\u4f1a\u6709\u5b83\u81ea\u5df1\u7684\u9700\u6c42\u548c\u751f\u547d\u5468\u671f\u3002<\/p>\n<p>WordPress \u662f\u57fa\u4e8e PHP \u7f16\u5199\u7684\u529f\u80fd\u5f3a\u5927\u7684 CMS\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5b83\u975e\u5e38\u5feb\u7684\u521b\u5efa\u4f60\u7684\u4ea7\u54c1\u3002\u7136\u800c\uff0c\u5b83\u5e76\u6ca1\u6709\u9075\u5faa\u6700\u8fd1 PHP \u7684\u53d8\u5316\u548c\u7ea6\u5b9a\uff0c\u4f46\u662f\u4f60\u53ef\u4ee5\u5c06\u5b83\u4e0e\u5176\u4ed6\u7c7b\u4f3c Laravel \u8fd9\u6837\u7684\u6846\u67b6\u4e00\u8d77\u4f7f\u7528\u6765\u5e73\u8861\u8fd9\u4e00\u70b9\u3002<\/p>\n<p><strong>Corcel<\/strong><\/p>\n<p>\u6211\u8ba4\u4e3a WordPress \u7684\u540e\u53f0\u7ba1\u7406\u9762\u677f\u5f88\u68d2\u3002\u5b83\u6709\u4e00\u5806\u63d2\u4ef6\uff0c\u53ef\u4ee5\u8ba9\u4f60\u5feb\u901f\u5730\u751f\u6210\u5b57\u6bb5\uff0c\u6587\u7ae0\u7c7b\u578b\uff0c\u56fe\u7247\uff0c\u4f5c\u7269\u7b49\u7b49\u3002\u8fd9\u771f\u7684\u5f88\u68d2\uff01<\/p>\n<p>\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u6709\u4e86&nbsp;Corcel&nbsp;\uff0c\u5b83\u53ef\u4ee5\u8f7b\u677e\u8ba9\u4f60\u4ece WordPress \u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u6570\u636e\u3002\u4f60\u53ea\u9700\u8981\u4f7f\u7528 Composer \u5728\u4f60\u7684 PHP \u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff08 Laravel \u6216\u5176\u4ed6\u6846\u67b6\uff09\u4e2d\u5b89\u88c5 WordPress \u548c Corcel \u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u5f53\u7136\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728 WordPress \u4e2d\u4f7f\u7528 MVC \uff01<\/p>\n<p>\u4f60\u53ef\u4ee5\u4e3a\u4f60\u7684 WordPress \u642d\u5efa\u63a7\u5236\u5668\u3001\u6a21\u578b\u548c\u89c6\u56fe\u3002Corcel \u4e3a\u4f60\u521b\u5efa\u4e86\u4e00\u4e2a\u6a21\u578b\u96c6\u5408\u6765\u68c0\u7d22\u6587\u7ae0\u3001\u9875\u9762\u548c\u83dc\u5355\u7b49\uff0c\u751a\u81f3\u8fd8\u53ef\u4ee5\u8fde\u63a5\u4e0d\u540c\u7684\u6570\u636e\u5e93\uff0c\u4e00\u4e2a\u7528\u4e8e Laravel \uff0c\u53e6\u4e00\u4e2a\u7528\u4e8e WordPress \u3002<\/p>\n<pre>&lt;?php \/\/ File: \/config\/database.php\n'connections' =&gt; [\n    'mysql' =&gt; [\n        'driver'    =&gt; 'mysql',\n        'host'      =&gt; 'localhost',\n        'database'  =&gt; 'app',\n        'username'  =&gt; 'admin'\n        'password'  =&gt; 'secret',\n        'charset'   =&gt; 'utf8',\n        'collation' =&gt; 'utf8_unicode_ci',\n        'prefix'    =&gt; '',\n        'strict'    =&gt; false,\n        'engine'    =&gt; null,\n    ],\n    'wordpress' =&gt; [\n        'driver'    =&gt; 'mysql',\n        'host'      =&gt; 'localhost',\n        'database'  =&gt; 'corcel',\n        'username'  =&gt; 'admin',\n        'password'  =&gt; 'secret',\n        'charset'   =&gt; 'utf8',\n        'collation' =&gt; 'utf8_unicode_ci',\n        'prefix'    =&gt; 'wp_',\n        'strict'    =&gt; false,\n        'engine'    =&gt; null,\n    ],\n    \n],<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e0b\u9762\u5f00\u59cb\u4ece WordPress \u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u4f60\u6240\u9700\u8981\u7684\u4e1c\u897f\uff1a<\/p>\n<pre>&lt;?php \/\/ File: \/app\/Http\/Controllers\/AnyController.php\n\/\/ ...\npublic function index()\n{\n    $posts = Post::published()-&gt;take(10)-&gt;get();\n    $page = Page::where('post_name', 'about')-&gt;first();\n    return view('posts.index', compact('posts', 'page'));\n}\n\/\/ ...<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6587\u7ae0\u7c7b\u578b\u4e0e\u81ea\u5b9a\u4e49\u5b57\u6bb5<\/strong><\/p>\n<p>\u4e0d\u77e5\u9053\u4f60\u662f\u5426\u4f7f\u7528\u8fc7\u9ad8\u7ea7\u81ea\u5b9a\u4e49\u5b57\u6bb5\u529f\u80fd\uff08 ACF \uff09\uff1f\u5728\u8fd9\u91cc\u4f60\u4e5f\u53ef\u4ee5\u5f97\u5230\u6240\u6709\u7684\u81ea\u5b9a\u4e49\u5b57\u6bb5\uff1a<\/p>\n<pre>&lt;?php\n$post = Post::find(1);\n$avatar = $post-&gt;meta-&gt;avatar;\n$phone = $post-&gt;meta-&gt;phone;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f60\u53ef\u4ee5\u521b\u5efa\u4e0e\u81ea\u5b9a\u4e49\u6587\u7ae0\u7c7b\u578b\u76f8\u5173\u7684\u81ea\u5b9a\u4e49\u6a21\u578b\uff1a<\/p>\n<pre>&lt;?php \nuse CorcelPost as Corcel;\nclass Service extends Corcel\n{\n    protected $postType = 'service';\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5173\u4e8e\u66f4\u591a\u7684\u529f\u80fd\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728 GitHub\uff08https:\/\/github.com\/corcel\/corcel\uff09 \u4ed3\u5e93\u4e2d\u67e5\u770b\u3002<br \/>\u4f60\u53ef\u4ee5\u5728\u4efb\u4f55 PHP \u6846\u67b6\u4e2d\u4f7f\u7528 Corcel\uff0c\u751a\u81f3\u662f\u50cf Slim\uff0cSilex \u8fd9\u6837\u7684\u5fae\u578b\u6846\u67b6\u3002\u5b83\u53ef\u4ee5\u8ba9\u4f60\u83b7\u5f97\u6240\u6709 WordPress \u7ba1\u7406\u9762\u677f\u6570\u636e\uff0c\u5e76\u53ef\u4ee5\u8ba9\u4f60\u4f7f\u7528\u81ea\u5b9a\u4e49\u8def\u7531\u3001\u63a7\u5236\u5668\u3001\u6a21\u578b\u548c\u89c6\u56fe\u6765\u7ec4\u7ec7\u4f60\u7684\u9879\u76ee\u3002<\/p>\n<p>\u6765\u7ed9 Corcel \u4e00\u4e2a\u673a\u4f1a\u5427\uff0c\u4e5f\u6b22\u8fce\u5927\u5bb6\u7ed9\u4e00\u4e9b\u5efa\u8bae\u6216\u8005\u76f4\u63a5\u8d21\u732e\u4ee3\u7801\uff0c\u8c22\u8c22\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5728WordPress\u4e2d\u4f7f\u7528Laravel\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>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;wordpress\u6559\u7a0b\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u5982\u4f55\u5728 wordpress \u4e2d\u4f7f\u7528 \uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01 Corcel \u8ba9\u4f60\u5728 WordPress \u4e2d\u4f7f\u7528 Laravel \u4f60\u60f3\u8fc7\u53ef\u4ee5\u5728 WordPress \u4e2d\u4f7f\u7528 Laravel \u6216\u8005\u4efb\u610f\u4e00\u79cd PHP \u6846\u67b6\u5417\uff1f&nbsp;Corcel&nbsp;\u53ef\u4ee5\u5e2e\u4f60\u5b9e\u73b0\uff01 \u5f00\u53d1\u7f51\u7ad9\u5e94\u7528\u5c31\u5e94\u8be5\u662f\u5feb\u6377\u5e76\u6709\u8da3\u7684\u3002\u5f53\u7136\u4e86\uff0c\u6bcf\u4e2a\u5e94\u7528\u90fd\u4f1a\u6709\u5b83\u81ea\u5df1\u7684\u9700\u6c42\u548c\u751f\u547d\u5468\u671f\u3002 WordPress \u662f\u57fa\u4e8e PHP \u7f16\u5199\u7684\u529f\u80fd\u5f3a\u5927\u7684 CMS\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5b83\u975e\u5e38\u5feb\u7684\u521b\u5efa\u4f60\u7684\u4ea7\u54c1\u3002\u7136\u800c\uff0c\u5b83\u5e76\u6ca1\u6709\u9075\u5faa\u6700\u8fd1 PHP \u7684\u53d8\u5316\u548c\u7ea6\u5b9a\uff0c\u4f46\u662f\u4f60\u53ef\u4ee5\u5c06\u5b83\u4e0e\u5176\u4ed6\u7c7b\u4f3c Laravel \u8fd9\u6837\u7684\u6846\u67b6\u4e00\u8d77\u4f7f\u7528\u6765\u5e73\u8861\u8fd9\u4e00\u70b9\u3002 Corcel \u6211\u8ba4\u4e3a WordPress \u7684\u540e\u53f0\u7ba1\u7406\u9762\u677f\u5f88\u68d2\u3002\u5b83\u6709\u4e00\u5806\u63d2\u4ef6\uff0c\u53ef\u4ee5\u8ba9\u4f60\u5feb\u901f\u5730\u751f\u6210\u5b57\u6bb5\uff0c\u6587\u7ae0\u7c7b\u578b\uff0c\u56fe\u7247\uff0c\u4f5c\u7269\u7b49\u7b49\u3002\u8fd9\u771f\u7684\u5f88\u68d2\uff01 \u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u6709\u4e86&nbsp;Corcel&nbsp;\uff0c\u5b83\u53ef\u4ee5\u8f7b\u677e\u8ba9\u4f60\u4ece WordPress \u6570\u636e\u5e93\u4e2d\u83b7\u53d6\u6570\u636e\u3002\u4f60\u53ea\u9700\u8981\u4f7f\u7528 Composer \u5728\u4f60\u7684 PHP \u5e94\u7528\u7a0b\u5e8f\u6846\u67b6\uff08 Laravel \u6216\u5176\u4ed6\u6846\u67b6\uff09\u4e2d\u5b89\u88c5 WordPress \u548c Corcel \u5c31\u53ef\u4ee5\u4e86\u3002 \u5f53\u7136\u6211\u4eec\u4e5f\u53ef\u4ee5\u5728 WordPress \u4e2d\u4f7f\u7528 MVC \uff01 \u4f60\u53ef\u4ee5\u4e3a\u4f60\u7684 WordPress \u642d\u5efa\u63a7\u5236\u5668\u3001\u6a21\u578b\u548c\u89c6\u56fe\u3002Corcel \u4e3a\u4f60\u521b\u5efa\u4e86\u4e00\u4e2a\u6a21\u578b\u96c6\u5408\u6765\u68c0\u7d22\u6587\u7ae0\u3001\u9875\u9762\u548c\u83dc\u5355\u7b49\uff0c\u751a\u81f3\u8fd8\u53ef\u4ee5\u8fde\u63a5\u4e0d\u540c\u7684\u6570\u636e\u5e93\uff0c\u4e00\u4e2a\u7528\u4e8e Laravel \uff0c\u53e6\u4e00\u4e2a\u7528\u4e8e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-32072","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32072","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=32072"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32072\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=32072"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=32072"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=32072"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}