{"id":74552,"date":"2024-01-04T00:31:35","date_gmt":"2024-01-03T16:31:35","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=74552"},"modified":"2024-01-04T00:31:35","modified_gmt":"2024-01-03T16:31:35","slug":"tjl","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/74552.html","title":{"rendered":"\u63a2\u7a76 Laravel Create Console Command"},"content":{"rendered":"
\u672c\u6587\u5c06\u6df1\u5165\u8ba8\u8bba Laravel \u4e2d\u91cd\u8981\u7684\u529f\u80fd\u4e4b\u4e00\uff0c\u5373\u5982\u4f55\u4f7f\u7528 create console command\u3002\u901a\u8fc7\u672c\u6587\u7684\u9610\u8ff0\uff0c\u60a8\u5c06\u5bf9\u8be5\u547d\u4ee4\u6709\u66f4\u6df1\u5165\u7684\u4e86\u89e3\u3002<\/p>\n
Laravel \u7684 Console Command \u662f\u4e00\u79cd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u5728\u547d\u4ee4\u884c\u754c\u9762\u4e2d\u6267\u884c\u5404\u79cd\u4efb\u52a1\u3002\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u4ee5\u76f4\u89c2\u3001\u7b80\u5355\u7684\u65b9\u5f0f\u6784\u5efa\u548c\u6267\u884c\u547d\u4ee4\u884c\u5e94\u7528\u7a0b\u5e8f\uff0c\u540c\u65f6\u5229\u7528 Laravel \u5f3a\u5927\u7684\u6846\u67b6\u529f\u80fd\u3002<\/p>\n
\u521b\u5efa Console Command \u662f\u975e\u5e38\u7b80\u5355\u7684\uff0c\u53ea\u9700\u51e0\u4e2a\u7b80\u5355\u7684\u6b65\u9aa4\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u8fd0\u884c\u4e00\u4e2a\u7279\u6b8a\u7684 Artisan \u547d\u4ee4\uff1a<\/p>\n
php artisan make:command YourCommandName<\/p><\/pre>\n\u8fd9\u5c06\u4e3a\u60a8\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Console Command \u7c7b\uff0c\u53ef\u4ee5\u5728
app\/Console\/Commands<\/code> \u76ee\u5f55\u4e0b\u627e\u5230\u3002<\/p>\n
Console Command \u7684\u5e94\u7528<\/h2>\n
\u547d\u4ee4\u884c\u4efb\u52a1<\/h3>\n
\u901a\u8fc7 Laravel \u7684 Console Command\uff0c\u60a8\u53ef\u4ee5\u8f7b\u677e\u5730\u521b\u5efa\u548c\u6267\u884c\u5404\u79cd\u547d\u4ee4\u884c\u4efb\u52a1\uff0c\u4f8b\u5982\u6570\u636e\u8fc1\u79fb\u3001\u6570\u636e\u586b\u5145\u3001\u6e05\u7406\u7f13\u5b58\u7b49\u3002\u8fd9\u4f7f\u5f97\u5f00\u53d1\u8fc7\u7a0b\u66f4\u52a0\u9ad8\u6548\u548c\u4fbf\u6377\u3002<\/p>\n
\u5b9a\u65f6\u4efb\u52a1<\/h3>\n
Console Command \u8fd8\u53ef\u4ee5\u7528\u4e8e\u521b\u5efa\u5b9a\u65f6\u4efb\u52a1\uff0c\u4f7f\u5f97\u67d0\u4e9b\u4efb\u52a1\u80fd\u591f\u5728\u7279\u5b9a\u7684\u65f6\u95f4\u95f4\u9694\u5185\u81ea\u52a8\u6267\u884c\u3002\u8fd9\u5bf9\u4e8e\u5b9a\u671f\u6570\u636e\u5907\u4efd\u3001\u65e5\u5fd7\u6e05\u7406\u7b49\u4efb\u52a1\u7279\u522b\u6709\u7528\u3002<\/p>\n
\u603b\u7ed3<\/h2>\n
\u901a\u8fc7\u672c\u6587\u7684\u5b66\u4e60\uff0c\u76f8\u4fe1\u60a8\u5df2\u7ecf\u5bf9 Laravel \u7684 Console Command \u6709\u4e86\u66f4\u6e05\u6670\u7684\u8ba4\u8bc6\u3002<\/strong>\u5b83\u4e0d\u4ec5\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u547d\u4ee4\u884c\u754c\u9762\uff0c\u8fd8\u8d4b\u4e88\u4e86\u5f00\u53d1\u8005\u5f3a\u5927\u7684\u63a7\u5236\u548c\u7075\u6d3b\u6027\u3002\u521b\u5efa\u548c\u6267\u884c Console Command \u662f Laravel \u5f00\u53d1\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\uff0c\u5e0c\u671b\u60a8\u80fd\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u5145\u5206\u5229\u7528\u8fd9\u4e00\u529f\u80fd\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u672c\u6587\u5c06\u6df1\u5165\u8ba8\u8bbaLaravel\u4e2d\u91cd\u8981\u7684\u529f\u80fd\u4e4b\u4e00\uff0c\u5373\u5982\u4f55\u4f7f\u7528createconsolecommand\u3002\u901a\u8fc7\u672c\u6587\u7684\u9610\u8ff0\uff0c\u60a8\u5c06\u5bf9\u8be5\u547d\u4ee4\u6709\u66f4\u6df1\u5165\u7684\u4e86\u89e3\u3002\u7406\u89e3Lara<\/p>\n","protected":false},"author":1,"featured_media":64183,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[52],"class_list":["post-74552","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-wxtx"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/74552","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=74552"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/74552\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/64183"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=74552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=74552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=74552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}