{"id":202454,"date":"2025-05-13T09:05:28","date_gmt":"2025-05-13T01:05:28","guid":{"rendered":"https:\/\/server.hk\/cnblog\/202454\/"},"modified":"2025-05-13T09:05:28","modified_gmt":"2025-05-13T01:05:28","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88%e6%82%a8%e5%ba%94%e8%af%a5%e5%9c%a8%e4%b8%8b%e4%b8%80%e4%b8%aa-php-%e9%a1%b9%e7%9b%ae%e4%b8%ad%e5%b0%9d%e8%af%95-lithe%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/202454\/","title":{"rendered":"\u4e3a\u4ec0\u4e48\u60a8\u5e94\u8be5\u5728\u4e0b\u4e00\u4e2a PHP \u9879\u76ee\u4e2d\u5c1d\u8bd5 Lithe\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u4e3a\u4ec0\u4e48\u60a8\u5e94\u8be5\u5728\u4e0b\u4e00\u4e2a PHP \u9879\u76ee\u4e2d\u5c1d\u8bd5 Lithe\uff1f<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5927\u5bb6\u597d\uff0c\u4eca\u5929\u672c\u4eba\u7ed9\u5927\u5bb6\u5e26\u6765\u6587\u7ae0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4e3a\u4ec0\u4e48\u60a8\u5e94\u8be5\u5728\u4e0b\u4e00\u4e2a PHP \u9879\u76ee\u4e2d\u5c1d\u8bd5 Lithe\uff1f\u300b<\/span>\uff0c\u6587\u4e2d\u5185\u5bb9\u4e3b\u8981\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span><\/span>\uff0c\u5982\u679c\u4f60\u5bf9<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u90a3\u5c31\u8bf7\u5404\u4f4d\u670b\u53cb\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427~\u5e0c\u671b\u80fd\u771f\u6b63\u5e2e\u5230\u4f60\u4eec\uff0c\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241022\/17295572336716f2f13c57e.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>lithe<\/strong> \u662f\u5bfb\u6c42\u7b80\u5355\u6027\u548c\u529f\u80fd\u4e4b\u95f4\u5e73\u8861\u7684\u5f00\u53d1\u4eba\u5458\u7684\u5b8c\u7f8e php \u6846\u67b6\u3002\u5982\u679c\u60a8\u538c\u5026\u4e86\u5bfc\u81f4\u5f00\u53d1\u7f13\u6162\u4e14\u4ee4\u4eba\u56f0\u60d1\u7684\u7e41\u7410\u6846\u67b6\uff0clithe \u63d0\u4f9b\u4e86\u4e00\u79cd\u6781\u7b80\u4f46\u6781\u5176\u7075\u6d3b\u7684\u65b9\u6cd5\uff0c\u65e8\u5728\u8ba9\u60a8\u7684\u5de5\u4f5c\u66f4\u5feb\u3001\u66f4\u9ad8\u6548\u3002<\/p>\n<h3> 1. <strong>\u8f7b\u4fbf\u4e14\u8d85\u5feb<\/strong> <\/h3>\n<p>lithe \u7684\u5f00\u53d1\u91cd\u70b9\u662f\u8f7b\u91cf\u7ea7\uff0c\u5b83\u5141\u8bb8\u60a8\u4ee5\u5f88\u5c11\u7684\u5f00\u9500\u521b\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002\u4e0e\u5176\u4ed6\u63d0\u4f9b\u5927\u91cf\u60a8\u5e76\u4e0d\u603b\u662f\u9700\u8981\u7684\u529f\u80fd\u7684\u6846\u67b6\u4e0d\u540c\uff0clithe \u53ea\u52a0\u8f7d\u5fc5\u9700\u7684\u529f\u80fd\uff0c\u4ece\u800c\u5b9e\u73b0\u66f4\u5feb\u7684\u6267\u884c\u901f\u5ea6\u3002\u8fd9\u975e\u5e38\u9002\u5408<strong>\u521d\u521b\u516c\u53f8<\/strong>\u6216\u654f\u6377\u6027\u81f3\u5173\u91cd\u8981\u7684 mvp\uff08\u6700\u5c0f\u53ef\u884c\u4ea7\u54c1\uff09\u9879\u76ee\u3002<\/p>\n<h3> 2. <strong>\u7b80\u5355\u7075\u6d3b\u7684\u8def\u7531<\/strong> <\/h3>\n<p>lithe \u7684\u4e00\u5927\u4eae\u70b9\u662f\u5176\u7b80\u5355\u4f46\u200b\u200b\u6781\u5176\u5f3a\u5927\u7684\u8def\u7531\u7cfb\u7edf\u3002\u5982\u679c\u60a8\u66fe\u7ecf\u4f7f\u7528\u8fc7 express.js\uff0c\u60a8\u4f1a\u611f\u5230\u5bbe\u81f3\u5982\u5f52\u3002\u8def\u7ebf\u521b\u5efa\u76f4\u89c2\u4e14\u8f7b\u677e\u652f\u6301\u52a8\u6001\u53c2\u6570\u3002<\/p>\n<pre>get('\/user\/:id', function ($req, $res) {\n    $res-&gt;send('user id: ' . $req-&gt;param('id'));\n});\n<\/pre>\n<p>\u8fd9\u4e2a\u793a\u4f8b\u5c55\u793a\u4e86\u76f4\u63a5\u5728\u8def\u7531\u4e2d\u6355\u83b7\u52a8\u6001\u53c2\u6570\u662f\u591a\u4e48\u5bb9\u6613\uff0c\u786e\u4fdd\u4e86\u7075\u6d3b\u6027\u3002<\/p>\n<h3> 3. <strong>\u53ef\u5b9a\u5236\u7684\u4e2d\u95f4\u4ef6<\/strong> <\/h3>\n<p>\u4e2d\u95f4\u4ef6\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u7ec4\u7ec7\u548c\u5b89\u5168\u6027\u7684\u91cd\u8981\u7ec4\u4ef6\u3002\u5728 lithe \u4e2d\uff0c\u60a8\u53ef\u4ee5\u5c06\u5b83\u4eec\u5e94\u7528\u4e8e\u5168\u5c40\u548c\u7279\u5b9a\u8def\u7ebf\uff0c\u4fdd\u6301\u4ee3\u7801\u6a21\u5757\u5316\u548c\u53ef\u91cd\u7528\u3002\u8fd9\u4f7f\u60a8\u53ef\u4ee5\u8f7b\u677e\u6dfb\u52a0\u8eab\u4efd\u9a8c\u8bc1\u3001\u9519\u8bef\u5904\u7406\u6216\u4efb\u4f55\u5176\u4ed6\u81ea\u5b9a\u4e49\u903b\u8f91\u3002<\/p>\n<pre>apply(function ($req, $res, $next) {\n    \/\/ Middleware de autentica\u00e7\u00e3o\n    if (!$req-&gt;session-&gt;has('loggedin')) {\n        return $res-&gt;status(403)-&gt;send('Acesso negado');\n    }\n    $next();\n});\n<\/pre>\n<h3> 4. <strong>\u4e0e\u6570\u636e\u5e93\u7684\u7b80\u5355\u96c6\u6210<\/strong> <\/h3>\n<p>lithe \u5141\u8bb8\u8fde\u63a5\u591a\u4e2a\u6570\u636e\u5e93\uff0c\u5305\u62ec <strong>pdo<\/strong>\u3001<strong>mysqli<\/strong>\u3001<strong>doctrine<\/strong> \u548c <strong>eloquent<\/strong>\uff0c\u4f7f\u5176\u9ad8\u5ea6\u7075\u6d3b\u5730\u6ee1\u8db3\u60a8\u7684\u5177\u4f53\u9700\u6c42\u3002\u8fd9\u79cd\u591a\u6837\u6027\u7684\u9009\u9879\u4f7f\u60a8\u53ef\u4ee5\u66f4\u8f7b\u677e\u5730\u9009\u62e9\u6700\u9002\u5408\u60a8\u9879\u76ee\u7684\u7cfb\u7edf\u3002<\/p>\n<p>\u6b64\u5916\uff0clithe \u652f\u6301<strong>\u6570\u636e\u5e93\u8fc1\u79fb<\/strong>\uff0c\u8fd9\u4f7f\u5f97\u76f4\u63a5\u4ece\u547d\u4ee4\u884c\u7ba1\u7406\u6570\u636e\u5e93\u7248\u672c\u548c\u67b6\u6784\u66f4\u6539\u53d8\u5f97\u5bb9\u6613\u3002<\/p>\n<h3> 5. <strong>\u91cf\u8eab\u5b9a\u5236\u7684\u6027\u80fd<\/strong> <\/h3>\n<p>\u91cd\u91cf\u548c\u590d\u6742\u6027\u66f4\u8f7b\uff0clithe \u5728\u751f\u4ea7\u73af\u5883\u4e2d\u63d0\u4f9b<strong>\u9ad8\u6027\u80fd<\/strong>\uff0c\u975e\u5e38\u9002\u5408\u9700\u8981\u5728\u4e0d\u635f\u5931\u901f\u5ea6\u7684\u60c5\u51b5\u4e0b\u6269\u5c55\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u5982\u679c\u60a8\u7684\u9879\u76ee\u9700\u8981\u589e\u957f\u5e76\u4ecd\u4fdd\u6301\u5feb\u901f\u6027\u80fd\uff0clithe \u662f\u5b8c\u7f8e\u7684\u9009\u62e9\u3002<\/p>\n<h3> 6. <strong>\u751f\u4ea7\u5c31\u7eea<\/strong> <\/h3>\n<p>\u5c3d\u7ba1\u8f7b\u91cf\u7ea7\u4e14\u7b80\u5355\uff0c\u4f46 lithe \u5df2\u4e3a\u751f\u4ea7\u73af\u5883\u505a\u597d\u51c6\u5907\uff0c\u5b8c\u5168\u652f\u6301\u52a0\u5bc6\u3001\u4f1a\u8bdd\u7ba1\u7406\u548c\u6587\u4ef6\u4e0a\u4f20\u3002\u5b83\u63d0\u4f9b\u4e86\u6784\u5efa\u5065\u58ee\u4e14\u5b89\u5168\u7684\u5e94\u7528\u7a0b\u5e8f\u6240\u9700\u7684\u6240\u6709\u5de5\u5177\u3002<\/p>\n<h3> 7. <strong>\u6e05\u6670\u5ba2\u89c2\u7684\u6587\u6863<\/strong> <\/h3>\n<p>lithe \u7684\u6587\u6863\u662f\u53e6\u4e00\u4e2a\u4eae\u70b9\u3002\u4ece\u7b2c\u4e00\u6b65\u5230\u521b\u5efa\u590d\u6742\u7684\u4e2d\u95f4\u4ef6\uff0c\u8be5\u6587\u6863\u5c06\u6307\u5bfc\u60a8\u5b8c\u6210\u8be5\u6846\u67b6\u7684\u5404\u4e2a\u65b9\u9762\u3002\u5373\u4f7f\u60a8\u662f web \u5f00\u53d1\u6216 php \u6846\u67b6\u9886\u57df\u7684\u65b0\u624b\uff0c\u60a8\u4e5f\u4f1a\u627e\u5230\u6e05\u6670\u5b9e\u7528\u7684\u793a\u4f8b\u6765\u7acb\u5373\u5f00\u59cb\u4f7f\u7528 lithe\u3002<\/p>\n<h3> 8. <strong>\u591a\u6a21\u677f\u5f15\u64ce\u652f\u6301<\/strong> <\/h3>\n<p>\u4f60\u60f3\u4f7f\u7528<strong>blade<\/strong>\u3001<strong>twig<\/strong>\uff0c\u8fd8\u662f\u53ea\u662f<strong>\u7eafphp<\/strong>\uff1f lithe \u652f\u6301\u8fd9\u4e9b\u548c\u5176\u4ed6\u6a21\u677f\u5f15\u64ce\uff0c\u8ba9\u60a8\u53ef\u4ee5\u7075\u6d3b\u5730\u9009\u62e9\u6e32\u67d3\u89c6\u56fe\u7684\u6700\u4f73\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<h3> 9. <strong>\u6a21\u5757\u5316\u751f\u6001\u7cfb\u7edf<\/strong> <\/h3>\n<p>lithe \u65e8\u5728\u4e0e\u5916\u90e8\u7ec4\u4ef6\u548c\u5e93\u517c\u5bb9\u3002\u8fd9\u610f\u5473\u7740\u60a8\u53ef\u4ee5\u5c06\u81ea\u5df1\u559c\u6b22\u7684 php \u5de5\u5177\u548c\u5e93\u5e26\u5165\u9879\u76ee\u4e2d\uff0c\u800c\u4e0d\u5fc5\u62c5\u5fc3\u4e0d\u517c\u5bb9\u3002\u4ece\u7f13\u5b58\u7ba1\u7406\u5668\u5230\u9a8c\u8bc1\u5e93\uff0clithe \u5141\u8bb8\u4e0e php \u751f\u6001\u7cfb\u7edf\u8fdb\u884c\u6d41\u7545\u96c6\u6210\u3002<\/p>\n<hr>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5bfb\u627e\u4e00\u4e2a\u5c0a\u91cd\u60a8\u7684\u65f6\u95f4\u3001\u4ee3\u7801\u5e76\u4ecd\u7136\u63d0\u4f9b\u589e\u957f\u7075\u6d3b\u6027\u7684\u6846\u67b6\uff0c<strong>lithe<\/strong> \u662f\u6b63\u786e\u7684\u9009\u62e9\u3002 lithe \u7ed3\u5408\u4e86\u5feb\u901f\u7684\u5b66\u4e60\u66f2\u7ebf\u3001\u5353\u8d8a\u7684\u6027\u80fd\u548c\u7075\u6d3b\u7684\u67b6\u6784\uff0c\u6709\u671b\u6210\u4e3a\u73b0\u4ee3 php \u5f00\u53d1\u7684\u6700\u4f73\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<p><strong>\u7acb\u5373\u4e0b\u8f7d lithe\uff0c\u770b\u770b\u5b83\u5982\u4f55\u6539\u53d8\u60a8\u7684 php \u5f00\u53d1\u65b9\u5f0f\uff01<\/strong><\/p>\n<p>\u5728\u6b64\u5904\u6d4f\u89c8\u5b8c\u6574\u6587\u6863<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300a\u4e3a\u4ec0\u4e48\u60a8\u5e94\u8be5\u5728\u4e0b\u4e00\u4e2a PHP \u9879\u76ee\u4e2d\u5c1d\u8bd5 Lithe\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<p> \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4ec0\u4e48\u60a8\u5e94\u8be5\u5728\u4e0b\u4e00\u4e2a PHP \u9879&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-202454","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=202454"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202454\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=202454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=202454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=202454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}