{"id":22637,"date":"2024-11-21T11:25:43","date_gmt":"2024-11-21T03:25:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/22637\/"},"modified":"2024-11-21T11:25:43","modified_gmt":"2024-11-21T03:25:43","slug":"laravel%e7%9a%84%e8%b7%af%e7%94%b1%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/22637\/","title":{"rendered":"laravel\u7684\u8def\u7531\u5982\u4f55\u67e5\u770b"},"content":{"rendered":"<p>laravel\u662f\u4e00\u6b3e\u6d41\u884c\u7684php\u6846\u67b6\uff0c\u5b83\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684mvc\u6846\u67b6\uff0c\u5305\u542b\u4e86\u8bb8\u591a\u5b9e\u7528\u7684\u529f\u80fd\u548c\u7ec4\u4ef6\uff0c\u6bd4\u5982\u8def\u7531\u7cfb\u7edf\u3002laravel\u7684\u8def\u7531\u7cfb\u7edf\u662f\u975e\u5e38\u5f3a\u5927\u548c\u7075\u6d3b\u7684\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u4eba\u5458\u65b9\u4fbf\u5730\u5b9a\u4e49\u548c\u7ba1\u7406\u5e94\u7528\u7a0b\u5e8f\u7684\u8def\u7531\u3002<\/p>\n<p>\u5728Laravel\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u201cartisan route:list\u201d\u547d\u4ee4\u6765\u67e5\u770b\u6240\u6709\u5df2\u5b9a\u4e49\u7684\u8def\u7531\u3002\u4e0b\u9762\u662f\u5982\u4f55\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u6765\u67e5\u770bLaravel\u7684\u8def\u7531\u3002<\/p>\n<p>\u6b65\u9aa41\uff1a\u6253\u5f00\u7ec8\u7aef\u6216\u547d\u4ee4\u884c<\/p>\n<p>\u5728\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\u6216\u547d\u4ee4\u884c\u754c\u9762\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u641c\u7d22\u680f\u4e2d\u952e\u5165\u201ccmd\u201d\u6765\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u3002\u5bf9\u4e8eMac\u548cLinux\u7528\u6237\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u6309\u4e0b\u201cControl + Alt + T\u201d\u7ec4\u5408\u952e\u6765\u6253\u5f00\u7ec8\u7aef\u3002<\/p>\n<p>\u6b65\u9aa42\uff1a\u8fdb\u5165Laravel\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u5f55<\/p>\n<p>\u4f7f\u7528\u201cCD\u201d\u547d\u4ee4\u8fdb\u5165\u60a8\u7684Laravel\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u7684Laravel\u5e94\u7528\u7a0b\u5e8f\u4f4d\u4e8e\u201c\/var\/www\/html\/myapp\u201d\u76ee\u5f55\u4e2d\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u5165\u8be5\u76ee\u5f55\uff1a<\/p>\n<pre>cd \/var\/www\/html\/myapp<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b65\u9aa43\uff1a\u8fd0\u884c\u201cartisan route:list\u201d\u547d\u4ee4<\/p>\n<p>\u5728\u60a8\u7684Laravel\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>php artisan route:list<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5f53\u60a8\u6309\u4e0b\u56de\u8f66\u65f6\uff0c\u60a8\u5c06\u770b\u5230\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u5185\u5bb9\u7684\u8f93\u51fa\uff1a<\/p>\n<pre>+--------+----------+------------------------+------+--------------------------------------------------------+------------+\n| Domain | Method   | URI                    | Name | Action                                                 | Middleware |\n+--------+----------+------------------------+------+--------------------------------------------------------+------------+\n|        | GET|HEAD | \/                      |      | Closure                                                | web        |\n|        | GET|HEAD | api\/user               |      | Closure                                                | api        |\n|        | GET|HEAD | hello                  |      | AppHttpControllersHelloController@index             | web        |\n|        | GET|HEAD | user\/{id}              |      | AppHttpControllersUserController@show              | web        |\n|        | POST     | user                   |      | AppHttpControllersUserController@store             | web        |\n+--------+----------+------------------------+------+--------------------------------------------------------+------------+<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u4e2a\u8868\u683c\u663e\u793a\u4e86\u5df2\u5b9a\u4e49\u7684\u6bcf\u4e2a\u8def\u7531\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u5305\u62ec\u57df\u540d\uff0cHTTP\u65b9\u6cd5\uff0cURI\uff0c\u8def\u7531\u540d\u79f0\uff0c\u65b9\u6cd5\uff0c\u4ee5\u53ca\u5e94\u7528\u4e8e\u8def\u7531\u7684\u4e2d\u95f4\u4ef6\u3002<\/p>\n<p>\u5982\u679c\u60a8\u7684Laravel\u5e94\u7528\u7a0b\u5e8f\u4e2d\u6709\u8bb8\u591a\u8def\u7531\uff0c\u60a8\u53ef\u4ee5\u6dfb\u52a0\u201c&#8211;sort=name\u201d\u9009\u9879\u4ee5\u6309\u540d\u79f0\u6392\u5e8f\u5b83\u4eec\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>php artisan route:list --sort=name<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u5c06\u6839\u636e\u8def\u7531\u540d\u79f0\u5bf9\u6240\u6709\u8def\u7531\u8fdb\u884c\u6392\u5e8f\u3002<\/p>\n<p>\u8fd8\u53ef\u4ee5\u4f7f\u7528\u201c&#8211;path=uri\u201d\u9009\u9879\u6765\u4ec5\u663e\u793a\u4e0e\u6307\u5b9aURI\u76f8\u5173\u7684\u8def\u7531\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>php artisan route:list --path=user<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u5c06\u53ea\u663e\u793aURI\u4e2d\u5305\u542b\u201cuser\u201d\u7684\u8def\u7531\u3002<\/p>\n<p>\u603b\u7ed3<\/p>\n<p>\u4f7f\u7528\u201cartisan route:list\u201d\u547d\u4ee4\u53ef\u4ee5\u8f7b\u677e\u67e5\u770b\u60a8\u7684Laravel\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5df2\u5b9a\u4e49\u7684\u6240\u6709\u8def\u7531\u3002\u6b64\u547d\u4ee4\u4e5f\u5141\u8bb8\u60a8\u4f7f\u7528\u4e0d\u540c\u7684\u9009\u9879\u548c\u8fc7\u6ee4\u5668\u6765\u67e5\u627e\u548c\u6392\u5e8f\u8def\u7531\u3002\u8fd9\u4e2a\u5c0f\u5c0f\u7684\u6280\u5de7\u53ef\u4ee5\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u7ec4\u7ec7\u548c\u7ba1\u7406\u60a8\u7684Laravel\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662flaravel\u7684\u8def\u7531\u5982\u4f55\u67e5\u770b\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\u6b3e\u6d41\u884c\u7684php\u6846\u67b6\uff0c\u5b83\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684mvc\u6846\u67b6\uff0c\u5305\u542b\u4e86\u8bb8\u591a\u5b9e\u7528\u7684\u529f\u80fd\u548c\u7ec4\u4ef6\uff0c\u6bd4\u5982\u8def\u7531\u7cfb\u7edf\u3002laravel\u7684\u8def\u7531\u7cfb\u7edf\u662f\u975e\u5e38\u5f3a\u5927\u548c\u7075\u6d3b\u7684\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u4eba\u5458\u65b9\u4fbf\u5730\u5b9a\u4e49\u548c\u7ba1\u7406\u5e94\u7528\u7a0b\u5e8f\u7684\u8def\u7531\u3002 \u5728Laravel\u5e94\u7528\u7a0b\u5e8f\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u201cartisan route:list\u201d\u547d\u4ee4\u6765\u67e5\u770b\u6240\u6709\u5df2\u5b9a\u4e49\u7684\u8def\u7531\u3002\u4e0b\u9762\u662f\u5982\u4f55\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\u6765\u67e5\u770bLaravel\u7684\u8def\u7531\u3002 \u6b65\u9aa41\uff1a\u6253\u5f00\u7ec8\u7aef\u6216\u547d\u4ee4\u884c \u5728\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u6253\u5f00\u4e00\u4e2a\u7ec8\u7aef\u6216\u547d\u4ee4\u884c\u754c\u9762\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u641c\u7d22\u680f\u4e2d\u952e\u5165\u201ccmd\u201d\u6765\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u3002\u5bf9\u4e8eMac\u548cLinux\u7528\u6237\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u6309\u4e0b\u201cControl + Alt + T\u201d\u7ec4\u5408\u952e\u6765\u6253\u5f00\u7ec8\u7aef\u3002 \u6b65\u9aa42\uff1a\u8fdb\u5165Laravel\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u5f55 \u4f7f\u7528\u201cCD\u201d\u547d\u4ee4\u8fdb\u5165\u60a8\u7684Laravel\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u7684Laravel\u5e94\u7528\u7a0b\u5e8f\u4f4d\u4e8e\u201c\/var\/www\/html\/myapp\u201d\u76ee\u5f55\u4e2d\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u5165\u8be5\u76ee\u5f55\uff1a cd \/var\/www\/html\/myapp \u767b\u5f55\u540e\u590d\u5236 \u6b65\u9aa43\uff1a\u8fd0\u884c\u201cartisan route:list\u201d\u547d\u4ee4 \u5728\u60a8\u7684Laravel\u5e94\u7528\u7a0b\u5e8f\u7684\u6839\u76ee\u5f55\u4e0b\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a php artisan route:list \u767b\u5f55\u540e\u590d\u5236 \u5f53\u60a8\u6309\u4e0b\u56de\u8f66\u65f6\uff0c\u60a8\u5c06\u770b\u5230\u7c7b\u4f3c\u4e8e\u4ee5\u4e0b\u5185\u5bb9\u7684\u8f93\u51fa\uff1a +&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+ | Domain | Method | URI | Name | Action | Middleware | +&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;-+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+&#8212;&#8212;+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;&#8212;&#8212;+ | | GET|HEAD | \/ | | Closure | web | | | GET|HEAD | api\/user | | [&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-22637","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22637","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=22637"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/22637\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=22637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=22637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=22637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}