{"id":25284,"date":"2024-11-21T08:35:24","date_gmt":"2024-11-21T00:35:24","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25284\/"},"modified":"2024-11-21T08:35:24","modified_gmt":"2024-11-21T00:35:24","slug":"laravel%e6%a1%86%e6%9e%b6%e5%92%8ctp%e7%9a%84%e5%bc%82%e5%90%8c%e7%82%b9%e5%9c%a8%e5%93%aa%e9%87%8c%e5%91%a2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25284\/","title":{"rendered":"laravel\u6846\u67b6\u548ctp\u7684\u5f02\u540c\u70b9\u5728\u54ea\u91cc\u5462"},"content":{"rendered":"<blockquote><p>\n  laravel \u548c tp \u6846\u67b6\u7684\u4e3b\u8981\u5dee\u5f02\u5728\u4e8e\u67b6\u6784\uff08mvc vs. mtv\uff09\u3001\u8def\u7531\u3001orm \u548c\u6a21\u677f\u5f15\u64ce\uff0c\u4ee5\u53ca\u793e\u533a\u652f\u6301\u529b\u5ea6\u7684\u4e0d\u540c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202404\/09\/2024040915512418603.jpg\" class=\"aligncenter\" title=\"laravel\u6846\u67b6\u548ctp\u7684\u5f02\u540c\u70b9\u5728\u54ea\u91cc\u5462\u63d2\u56fe\" alt=\"laravel\u6846\u67b6\u548ctp\u7684\u5f02\u540c\u70b9\u5728\u54ea\u91cc\u5462\u63d2\u56fe\" \/><\/p>\n<p><strong>Laravel \u548c TP \u6846\u67b6\u7684\u4e3b\u8981\u5f02\u540c\u70b9<\/strong><\/p>\n<p><strong>\u5f02\u70b9\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>\u67b6\u6784\uff1a<\/strong>Laravel \u91c7\u7528 Model-View-Controller (MVC) \u67b6\u6784\uff0c\u800c TP \u91c7\u7528 Model-Template-View (MTV) \u67b6\u6784\u3002MVC \u4e13\u6ce8\u4e8e\u5206\u79bb\u5e94\u7528\u7a0b\u5e8f\u7684\u4e1a\u52a1\u903b\u8f91\u3001\u8868\u793a\u5c42\u548c\u63a7\u5236\u6d41\uff0c\u800c MTV \u5219\u5f3a\u8c03\u6a21\u677f\u5f15\u64ce\u548c\u4ee3\u7801\u7b80\u6d01\u6027\u3002<\/li>\n<li> <strong>\u8def\u7531\uff1a<\/strong>Laravel \u4f7f\u7528\u4f18\u96c5\u7684\u8def\u7531\u7cfb\u7edf\uff0c\u57fa\u4e8e RESTful \u539f\u5219\uff0c\u800c TP \u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u8def\u7531\u673a\u5236\uff0c\u5141\u8bb8\u7075\u6d3b\u5b9a\u4e49 URL \u6a21\u5f0f\u3002<\/li>\n<li> <strong>ORM\uff1a<\/strong>Laravel \u5185\u7f6e\u4e86 Eloquent ORM\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u65b9\u4fbf\u7684 API \u6765\u4e0e\u6570\u636e\u5e93\u8fdb\u884c\u4ea4\u4e92\uff0c\u800c TP \u4f7f\u7528\u7684\u662f ThinkPHP ORM\uff0c\u5b83\u540c\u6837\u63d0\u4f9b\u4e86 ORM \u529f\u80fd\uff0c\u4f46 API \u4e0d\u540c\u3002<\/li>\n<li> <strong>\u6a21\u677f\u5f15\u64ce\uff1a<\/strong>Laravel \u4f7f\u7528 Blade \u6a21\u677f\u5f15\u64ce\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u6d01\u3001\u76f4\u89c2\u7684\u8bed\u6cd5\uff0c\u800c TP \u4f7f\u7528\u7684\u662f Smarty \u6a21\u677f\u5f15\u64ce\uff0c\u5b83\u4ee5\u7075\u6d3b\u6027\u8457\u79f0\u3002<\/li>\n<li> <strong>\u793e\u533a\u652f\u6301\uff1a<\/strong>Laravel \u62e5\u6709\u4e00\u4e2a\u5e9e\u5927\u548c\u6d3b\u8dc3\u7684\u793e\u533a\uff0c\u63d0\u4f9b\u5927\u91cf\u7684\u6587\u6863\u3001\u6559\u7a0b\u548c\u6269\u5c55\u5305\uff0c\u800c TP \u7684\u793e\u533a\u8f83\u5c0f\uff0c\u4f46\u4ecd\u7136\u63d0\u4f9b\u5b98\u65b9\u6587\u6863\u548c\u4e00\u4e9b\u7b2c\u4e09\u65b9\u8d44\u6e90\u3002<\/li>\n<\/ul>\n<p><strong>\u540c\u70b9\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>\u7528\u9014\uff1a<\/strong>Laravel \u548c TP \u90fd\u662f\u529f\u80fd\u9f50\u5168\u7684 PHP \u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u5404\u79cd Web \u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<li> <strong>PHP \u7248\u672c\u652f\u6301\uff1a<\/strong>\u4e24\u4e2a\u6846\u67b6\u90fd\u652f\u6301\u6700\u65b0\u7684 PHP \u7248\u672c\uff0c\u786e\u4fdd\u4e0e\u6700\u65b0\u6280\u672f\u517c\u5bb9\u3002<\/li>\n<li> <strong>\u5b89\u5168\u529f\u80fd\uff1a<\/strong>Laravel \u548c TP \u90fd\u5305\u542b\u5185\u7f6e\u7684\u5b89\u5168\u529f\u80fd\uff0c\u5982 CSRF \u4fdd\u62a4\u548c SQL \u6ce8\u5165\u9632\u5fa1\uff0c\u4ee5\u63d0\u9ad8\u5e94\u7528\u7a0b\u5e8f\u5b89\u5168\u6027\u3002<\/li>\n<li> <strong>\u7075\u6d3b\u6027\uff1a<\/strong>\u8fd9\u4e24\u4e2a\u6846\u67b6\u90fd\u63d0\u4f9b\u4e86\u7075\u6d3b\u6027\uff0c\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u6839\u636e\u9700\u8981\u5b9a\u5236\u548c\u6269\u5c55\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<li> <strong>\u6570\u636e\u5e93\u8fde\u63a5\uff1a<\/strong>\u4e24\u4e2a\u6846\u67b6\u90fd\u652f\u6301\u8fde\u63a5\u5230\u5404\u79cd\u6570\u636e\u5e93\uff0c\u5982 MySQL\u3001PostgreSQL \u548c SQLite\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6846\u67b6\u548ctp\u7684\u5f02\u540c\u70b9\u5728\u54ea\u91cc\u5462\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>laravel \u548c tp \u6846\u67b6\u7684\u4e3b\u8981\u5dee\u5f02\u5728\u4e8e\u67b6\u6784\uff08mvc vs. mtv\uff09\u3001\u8def\u7531\u3001orm \u548c\u6a21\u677f\u5f15\u64ce\uff0c\u4ee5\u53ca\u793e\u533a\u652f\u6301\u529b\u5ea6\u7684\u4e0d\u540c\u3002 Laravel \u548c TP \u6846\u67b6\u7684\u4e3b\u8981\u5f02\u540c\u70b9 \u5f02\u70b9\uff1a \u67b6\u6784\uff1aLaravel \u91c7\u7528 Model-View-Controller (MVC) \u67b6\u6784\uff0c\u800c TP \u91c7\u7528 Model-Template-View (MTV) \u67b6\u6784\u3002MVC \u4e13\u6ce8\u4e8e\u5206\u79bb\u5e94\u7528\u7a0b\u5e8f\u7684\u4e1a\u52a1\u903b\u8f91\u3001\u8868\u793a\u5c42\u548c\u63a7\u5236\u6d41\uff0c\u800c MTV \u5219\u5f3a\u8c03\u6a21\u677f\u5f15\u64ce\u548c\u4ee3\u7801\u7b80\u6d01\u6027\u3002 \u8def\u7531\uff1aLaravel \u4f7f\u7528\u4f18\u96c5\u7684\u8def\u7531\u7cfb\u7edf\uff0c\u57fa\u4e8e RESTful \u539f\u5219\uff0c\u800c TP \u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u8def\u7531\u673a\u5236\uff0c\u5141\u8bb8\u7075\u6d3b\u5b9a\u4e49 URL \u6a21\u5f0f\u3002 ORM\uff1aLaravel \u5185\u7f6e\u4e86 Eloquent ORM\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u65b9\u4fbf\u7684 API \u6765\u4e0e\u6570\u636e\u5e93\u8fdb\u884c\u4ea4\u4e92\uff0c\u800c TP \u4f7f\u7528\u7684\u662f ThinkPHP ORM\uff0c\u5b83\u540c\u6837\u63d0\u4f9b\u4e86 ORM \u529f\u80fd\uff0c\u4f46 API \u4e0d\u540c\u3002 \u6a21\u677f\u5f15\u64ce\uff1aLaravel \u4f7f\u7528 Blade \u6a21\u677f\u5f15\u64ce\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u6d01\u3001\u76f4\u89c2\u7684\u8bed\u6cd5\uff0c\u800c TP \u4f7f\u7528\u7684\u662f Smarty \u6a21\u677f\u5f15\u64ce\uff0c\u5b83\u4ee5\u7075\u6d3b\u6027\u8457\u79f0\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-25284","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25284","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=25284"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25284\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}