前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Laravel Command命令行

Laravel Command命令行

作者头像
苦咖啡
发布2018-04-28 13:26:15
6350
发布2018-04-28 13:26:15
举报
文章被收录于专栏:我的博客我的博客我的博客

make:command php artisan make:command Test/Test生成新命令 在app/Console/Kernel.php文件当中注册命令 protected $commands = [ // TestCommand::class, ]; 编辑命令 /** * The name and signature of the console command. * * @var string */ protected $signature = ‘test:test {name} {date?} {default=default} {–op1=}’; //{name} 必须参数 {date?} 非必须 {default=default}默认参数 {–op1}设置项 /** * The console command description. * * @var string */ protected $description = ‘命令描述’;

/** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); }

/** * Execute the console command. * * @return mixed */ public function handle() { $argument = $this->argument(); print_r($argument); echo $this->option(‘op1’); $this->info(‘提示信息’); } 执行命令 php artisan test:test name1 date1 default –op1=option1 //程序调用 Artisan::call(“test:test”, array(‘name’ => ‘test’, ‘date’ => ‘date1’, ‘default’ => ‘def’,’–op1′ => ‘option’));

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年3月24日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档