{"id":25266,"date":"2024-11-21T13:24:23","date_gmt":"2024-11-21T05:24:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25266\/"},"modified":"2024-11-21T13:24:23","modified_gmt":"2024-11-21T05:24:23","slug":"laravel%e6%80%8e%e4%b9%88%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25266\/","title":{"rendered":"laravel\u600e\u4e48\u7528"},"content":{"rendered":"<blockquote><p>\n  laravel \u662f\u4e00\u4e2a php web \u6846\u67b6\uff0c\u7528\u4e8e\u521b\u5efa\u548c\u7ef4\u62a4\u590d\u6742 web \u5e94\u7528\u7a0b\u5e8f\u3002\u5165\u95e8\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5 laravel\u542f\u52a8\u5f00\u53d1\u670d\u52a1\u5668\u521b\u5efa\u6a21\u578b\u521b\u5efa\u63a7\u5236\u5668\u5b9a\u4e49\u8def\u7531\u6e32\u67d3\u89c6\u56fe\u8fc1\u79fb\u6570\u636e\u5e93\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202404\/09\/2024040914392523913.jpg\" class=\"aligncenter\" title=\"laravel\u600e\u4e48\u7528\u63d2\u56fe\" alt=\"laravel\u600e\u4e48\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>Laravel \u7b80\u4ecb<\/strong><\/p>\n<p>Laravel \u662f\u4e00\u79cd\u514d\u8d39\u5f00\u6e90\u7684 PHP Web \u6846\u67b6\uff0c\u4ee5\u5176\u4f18\u96c5\u7684\u8bed\u6cd5\u548c\u5f3a\u5927\u7684\u529f\u80fd\u800c\u95fb\u540d\u3002\u5b83\u65e8\u5728\u521b\u5efa\u548c\u7ef4\u62a4\u590d\u6742 Web \u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p><strong>\u5165\u95e8 Laravel<\/strong><\/p>\n<p><strong>1. \u5b89\u88c5 Laravel<\/strong><\/p>\n<ul>\n<li>\u786e\u4fdd\u5df2\u5b89\u88c5 PHP 7.3 \u6216\u66f4\u9ad8\u7248\u672c\u3002<\/li>\n<li>\u4f7f\u7528 Composer \u5b89\u88c5 Laravel\uff1a global require \/installer\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff1alaravel new project-name\u3002<\/li>\n<\/ul>\n<p><strong>2. \u542f\u52a8\u5f00\u53d1\u670d\u52a1\u5668<\/strong><\/p>\n<ul>\n<li>\u5bfc\u822a\u5230\u9879\u76ee\u76ee\u5f55\uff1acd project-name\u3002<\/li>\n<li>\u542f\u52a8\u5f00\u53d1\u670d\u52a1\u5668\uff1aphp artisan serve\u3002<\/li>\n<li>\u5e94\u7528\u7a0b\u5e8f\u5c06\u5728 http:\/\/localhost:8000 \u8fd0\u884c\u3002<\/li>\n<\/ul>\n<p><strong>3. \u521b\u5efa\u6a21\u578b<\/strong><\/p>\n<ul>\n<li>\u6a21\u578b\u4ee3\u8868\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u6570\u636e\u3002<\/li>\n<li>\u4f7f\u7528 Artisan \u547d\u4ee4\u521b\u5efa\u6a21\u578b\uff1aphp artisan make:model ModelName\u3002<\/li>\n<\/ul>\n<p><strong>4. \u521b\u5efa\u63a7\u5236\u5668<\/strong><\/p>\n<ul>\n<li>\u63a7\u5236\u5668\u5904\u7406\u7528\u6237\u8bf7\u6c42\u5e76\u4e0e\u6a21\u578b\u4ea4\u4e92\u3002<\/li>\n<li>\u4f7f\u7528 Artisan \u547d\u4ee4\u521b\u5efa\u63a7\u5236\u5668\uff1aphp artisan make:controller ControllerName\u3002<\/li>\n<\/ul>\n<p><strong>5. \u5b9a\u4e49\u8def\u7531<\/strong><\/p>\n<ul>\n<li>\u8def\u7531\u5c06 URL \u6620\u5c04\u5230\u63a7\u5236\u5668\u65b9\u6cd5\u3002<\/li>\n<li>\u5728 routes\/web.php \u4e2d\u5b9a\u4e49\u8def\u7531\uff1a<\/li>\n<\/ul>\n<pre>Route::get('\/route-name', 'ControllerName@method');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>6. \u6e32\u67d3\u89c6\u56fe<\/strong><\/p>\n<ul>\n<li>\u89c6\u56fe\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u7528\u6237\u754c\u9762\u3002<\/li>\n<li>\u5728\u63a7\u5236\u5668\u4e2d\u4f7f\u7528 view() \u65b9\u6cd5\u6e32\u67d3\u89c6\u56fe\uff1a<\/li>\n<\/ul>\n<pre>return view('view-name');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>7. \u8fc1\u79fb\u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>Laravel \u4f7f\u7528\u8fc1\u79fb\u6765\u7ba1\u7406\u6570\u636e\u5e93\u67b6\u6784\u3002<\/li>\n<li>\u4f7f\u7528 Artisan \u547d\u4ee4\u521b\u5efa\u8fc1\u79fb\uff1aphp artisan make:migration create_table_name\u3002<\/li>\n<li>\u8fd0\u884c\u8fc1\u79fb\uff1aphp artisan migrate\u3002<\/li>\n<\/ul>\n<p><strong>\u9644\u52a0\u8d44\u6e90<\/strong><\/p>\n<ul>\n<li>[Laravel \u5b98\u65b9\u6587\u6863](https:\/\/laravel.com\/docs)<\/li>\n<li>[Laravel \u6559\u7a0b](https:\/\/laracasts.com\/)<\/li>\n<li>[Laravel \u793e\u533a\u8bba\u575b](https:\/\/laracasts.com\/discuss)<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u7528\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 \u662f\u4e00\u4e2a php web \u6846\u67b6\uff0c\u7528\u4e8e\u521b\u5efa\u548c\u7ef4\u62a4\u590d\u6742 web \u5e94\u7528\u7a0b\u5e8f\u3002\u5165\u95e8\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5 laravel\u542f\u52a8\u5f00\u53d1\u670d\u52a1\u5668\u521b\u5efa\u6a21\u578b\u521b\u5efa\u63a7\u5236\u5668\u5b9a\u4e49\u8def\u7531\u6e32\u67d3\u89c6\u56fe\u8fc1\u79fb\u6570\u636e\u5e93 Laravel \u7b80\u4ecb Laravel \u662f\u4e00\u79cd\u514d\u8d39\u5f00\u6e90\u7684 PHP Web \u6846\u67b6\uff0c\u4ee5\u5176\u4f18\u96c5\u7684\u8bed\u6cd5\u548c\u5f3a\u5927\u7684\u529f\u80fd\u800c\u95fb\u540d\u3002\u5b83\u65e8\u5728\u521b\u5efa\u548c\u7ef4\u62a4\u590d\u6742 Web \u5e94\u7528\u7a0b\u5e8f\u3002 \u5165\u95e8 Laravel 1. \u5b89\u88c5 Laravel \u786e\u4fdd\u5df2\u5b89\u88c5 PHP 7.3 \u6216\u66f4\u9ad8\u7248\u672c\u3002 \u4f7f\u7528 Composer \u5b89\u88c5 Laravel\uff1a global require \/installer\u3002 \u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff1alaravel new project-name\u3002 2. \u542f\u52a8\u5f00\u53d1\u670d\u52a1\u5668 \u5bfc\u822a\u5230\u9879\u76ee\u76ee\u5f55\uff1acd project-name\u3002 \u542f\u52a8\u5f00\u53d1\u670d\u52a1\u5668\uff1aphp artisan serve\u3002 \u5e94\u7528\u7a0b\u5e8f\u5c06\u5728 http:\/\/localhost:8000 \u8fd0\u884c\u3002 3. \u521b\u5efa\u6a21\u578b \u6a21\u578b\u4ee3\u8868\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u6570\u636e\u3002 \u4f7f\u7528 Artisan \u547d\u4ee4\u521b\u5efa\u6a21\u578b\uff1aphp artisan make:model ModelName\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-25266","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25266","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=25266"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25266\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}