{"id":21588,"date":"2024-11-19T13:23:14","date_gmt":"2024-11-19T05:23:14","guid":{"rendered":"https:\/\/fwq.ai\/blog\/21588\/"},"modified":"2024-11-19T13:23:14","modified_gmt":"2024-11-19T05:23:14","slug":"phpstorm%e6%80%8e%e4%b9%88%e5%88%9b%e5%bb%ba%e6%8e%a7%e5%88%b6%e5%99%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/21588\/","title":{"rendered":"phpstorm\u600e\u4e48\u521b\u5efa\u63a7\u5236\u5668"},"content":{"rendered":"<blockquote><p>\n  \u5728 phpstorm \u4e2d\u521b\u5efa\u63a7\u5236\u5668\uff0c\u53ea\u9700\uff1a1. \u53f3\u952e\u5355\u51fb\u63a7\u5236\u5668\u6240\u5728\u76ee\u5f55\uff0c\u9009\u62e9\u201c\u65b0\u5efa\u201d-&gt;\u201c\u63a7\u5236\u5668\u201d\uff1b2. \u5b9a\u4e49\u63a7\u5236\u5668\u903b\u8f91\uff1b3. \u5728 routes\/web.php \u4e2d\u7ed1\u5b9a\u8def\u7531\uff1b4. \u5bfc\u822a\u81f3\u76f8\u5e94 url \u8bbf\u95ee\u63a7\u5236\u5668\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/05\/2024060500391770041.jpg\" class=\"aligncenter\" title=\"phpstorm\u600e\u4e48\u521b\u5efa\u63a7\u5236\u5668\u63d2\u56fe\" alt=\"phpstorm\u600e\u4e48\u521b\u5efa\u63a7\u5236\u5668\u63d2\u56fe\" \/><\/p>\n<p><strong>PhpStorm \u4e2d\u521b\u5efa\u63a7\u5236\u5668<\/strong><\/p>\n<p>\u5728 PhpStorm \u4e2d\u521b\u5efa\u63a7\u5236\u5668\u975e\u5e38\u7b80\u5355\uff0c\u4e0b\u9762\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u521b\u5efa\u65b0\u63a7\u5236\u5668\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u9879\u76ee\u6d4f\u89c8\u5668\u4e2d\uff0c\u53f3\u952e\u5355\u51fb\u63a7\u5236\u5668\u6240\u5728\u7684\u76ee\u5f55\uff08\u901a\u5e38\u662f app\/Http\/Controllers\uff09\u3002<\/li>\n<li>\u9009\u62e9 <strong>\u65b0\u5efa<\/strong> -&gt; <strong>\u63a7\u5236\u5668<\/strong>\u3002<\/li>\n<li>\u5728\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u4e2d\uff0c\u8f93\u5165\u63a7\u5236\u5668\u540d\u79f0\u3002<\/li>\n<li>\u53ef\u9009\uff1a\u9009\u4e2d <strong>\u751f\u6210\u8d44\u6e90\u63a7\u5236\u5668<\/strong> \u521b\u5efa\u57fa\u672c\u7684 CRUD \u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<p><strong>2. \u5b9a\u4e49\u63a7\u5236\u5668\u903b\u8f91\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>PhpStorm \u5c06\u4e3a\u65b0\u63a7\u5236\u5668\u521b\u5efa\u6587\u4ef6\u3002<\/li>\n<li>\u5728\u63a7\u5236\u5668\u6587\u4ef6\u4e2d\uff0c\u5b9a\u4e49\u63a7\u5236\u5668\u903b\u8f91\uff0c\u4f8b\u5982\u65b9\u6cd5\u548c\u5c5e\u6027\u3002<\/li>\n<li>\u5bf9\u4e8e CRUD \u64cd\u4f5c\uff0c\u8d44\u6e90\u63a7\u5236\u5668\u5c06\u63d0\u4f9b\u57fa\u672c\u7684\u589e\u5220\u6539\u67e5 (CRUD) \u65b9\u6cd5\u3002<\/li>\n<\/ul>\n<p><strong>3. \u7ed1\u5b9a\u8def\u7531\uff1a<\/strong><\/p>\n<ul>\n<li>\u4e3a\u4e86\u8ba9\u63a7\u5236\u5668\u53ef\u7528\u4e8e Web \u8bf7\u6c42\uff0c\u9700\u8981\u5728 routes\/web.php \u6587\u4ef6\u4e2d\u7ed1\u5b9a\u8def\u7531\u3002<\/li>\n<li>\u4f8b\u5982\uff0c\u5bf9\u4e8e\u8d44\u6e90\u63a7\u5236\u5668\uff0c\u5c06\u751f\u6210\u4ee5\u4e0b\u8def\u7531\uff1a<\/li>\n<\/ul>\n<pre>Route::resource('posts', 'PostController');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u8bbf\u95ee\u63a7\u5236\u5668\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u6d4f\u89c8\u5668\u4e2d\u5bfc\u822a\u5230\u76f8\u5e94\u7684 URL\uff08\u4f8b\u5982\uff0c\/posts\uff09\u3002<\/li>\n<li>\u63a7\u5236\u5668\u5c06\u5904\u7406\u8bf7\u6c42\u5e76\u751f\u6210\u54cd\u5e94\u3002<\/li>\n<\/ul>\n<p><strong>\u5176\u4ed6\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>PhpStorm \u63d0\u4f9b\u4ee3\u7801\u63d0\u793a\u548c\u81ea\u52a8\u5b8c\u6210\uff0c\u4ee5\u5e2e\u52a9\u521b\u5efa\u548c\u5b9a\u4e49\u63a7\u5236\u5668\u3002<\/li>\n<li>\u53ef\u4ee5\u4f7f\u7528 php artisan make:controller \u547d\u4ee4\u901a\u8fc7\u547d\u4ee4\u884c\u521b\u5efa\u63a7\u5236\u5668\u3002<\/li>\n<li>\u63a7\u5236\u5668\u540d\u79f0\u5e94\u9075\u5faa\u547d\u540d\u7ea6\u5b9a\uff0c\u4f7f\u7528\u590d\u6570\u5f62\u5f0f\uff08\u4f8b\u5982\uff0cPostController\uff09\u3002<\/li>\n<li>\u786e\u4fdd\u63a7\u5236\u5668\u540d\u79f0\u5728\u547d\u540d\u7a7a\u95f4\u4e2d\u552f\u4e00\uff08\u4f8b\u5982\uff0cAppHttpControllersPostController\uff09\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u521b\u5efa\u63a7\u5236\u5668\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>\u5728 phpstorm \u4e2d\u521b\u5efa\u63a7\u5236\u5668\uff0c\u53ea\u9700\uff1a1. \u53f3\u952e\u5355\u51fb\u63a7\u5236\u5668\u6240\u5728\u76ee\u5f55\uff0c\u9009\u62e9\u201c\u65b0\u5efa\u201d-&gt;\u201c\u63a7\u5236\u5668\u201d\uff1b2. \u5b9a\u4e49\u63a7\u5236\u5668\u903b\u8f91\uff1b3. \u5728 routes\/web.php \u4e2d\u7ed1\u5b9a\u8def\u7531\uff1b4. \u5bfc\u822a\u81f3\u76f8\u5e94 url \u8bbf\u95ee\u63a7\u5236\u5668\u3002 PhpStorm \u4e2d\u521b\u5efa\u63a7\u5236\u5668 \u5728 PhpStorm \u4e2d\u521b\u5efa\u63a7\u5236\u5668\u975e\u5e38\u7b80\u5355\uff0c\u4e0b\u9762\u662f\u8be6\u7ec6\u6b65\u9aa4\uff1a 1. \u521b\u5efa\u65b0\u63a7\u5236\u5668\uff1a \u5728\u9879\u76ee\u6d4f\u89c8\u5668\u4e2d\uff0c\u53f3\u952e\u5355\u51fb\u63a7\u5236\u5668\u6240\u5728\u7684\u76ee\u5f55\uff08\u901a\u5e38\u662f app\/Http\/Controllers\uff09\u3002 \u9009\u62e9 \u65b0\u5efa -&gt; \u63a7\u5236\u5668\u3002 \u5728\u5f39\u51fa\u7684\u5bf9\u8bdd\u6846\u4e2d\uff0c\u8f93\u5165\u63a7\u5236\u5668\u540d\u79f0\u3002 \u53ef\u9009\uff1a\u9009\u4e2d \u751f\u6210\u8d44\u6e90\u63a7\u5236\u5668 \u521b\u5efa\u57fa\u672c\u7684 CRUD \u64cd\u4f5c\u3002 2. \u5b9a\u4e49\u63a7\u5236\u5668\u903b\u8f91\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b PhpStorm \u5c06\u4e3a\u65b0\u63a7\u5236\u5668\u521b\u5efa\u6587\u4ef6\u3002 \u5728\u63a7\u5236\u5668\u6587\u4ef6\u4e2d\uff0c\u5b9a\u4e49\u63a7\u5236\u5668\u903b\u8f91\uff0c\u4f8b\u5982\u65b9\u6cd5\u548c\u5c5e\u6027\u3002 \u5bf9\u4e8e CRUD \u64cd\u4f5c\uff0c\u8d44\u6e90\u63a7\u5236\u5668\u5c06\u63d0\u4f9b\u57fa\u672c\u7684\u589e\u5220\u6539\u67e5 (CRUD) \u65b9\u6cd5\u3002 3. \u7ed1\u5b9a\u8def\u7531\uff1a \u4e3a\u4e86\u8ba9\u63a7\u5236\u5668\u53ef\u7528\u4e8e Web \u8bf7\u6c42\uff0c\u9700\u8981\u5728 routes\/web.php \u6587\u4ef6\u4e2d\u7ed1\u5b9a\u8def\u7531\u3002 \u4f8b\u5982\uff0c\u5bf9\u4e8e\u8d44\u6e90\u63a7\u5236\u5668\uff0c\u5c06\u751f\u6210\u4ee5\u4e0b\u8def\u7531\uff1a Route::resource(&#8216;posts&#8217;, &#8216;PostController&#8217;); \u767b\u5f55\u540e\u590d\u5236 4. \u8bbf\u95ee\u63a7\u5236\u5668\uff1a \u5728\u6d4f\u89c8\u5668\u4e2d\u5bfc\u822a\u5230\u76f8\u5e94\u7684 [&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-21588","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21588","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=21588"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/21588\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=21588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=21588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=21588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}