一起源码网

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
猜你喜欢
查看: 8893|回复: 1
打印 上一主题 下一主题

详解Laravel的任务调度console

[复制链接]

0

主题

0

帖子

1万

积分

钻石会员

Rank: 8Rank: 8

积分
17424
QQ
跳转到指定楼层
楼主
发表于 2020-5-28 04:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本文主要给大家简单介绍了Laravel中任务调度console使用方法,并附上一个简单的示例,希望对大家学习使用console能够有所帮助。

适用场景:分析数据(日志)

php artisan make:console 你的命令类名

示例:

php artisan make:console Check

在appConsoleCommands目录下已生成一个Check.php文件

<?php

namespace AppConsoleCommands;

use IlluminateConsoleCommand;

class Check extends Command
{
  /**
   * The name and signature of the console command.
   *
   * @var string
   */
  protected $signature = 'command:name';

  /**
   * The console command description.
   *
   * @var string
   */
  protected $description = 'Command description';

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

  /**
   * Execute the console command.
   *
   * @return mixed
   */
  public function handle()
  {
    //
  }
}

你可以把$signature改为你要的命令名称

protected $signature = 'check';

此时还不能在控制台中调用,需要在Kernel.php中注册。

protected $commands = [
    'AppConsoleCommandsCheck'
];

你已经可以在控制台中使用这个命令了

php artisan check

点评:似乎也没啥用,因为php本身也可以不用Laravel框架来使用CLI命令行。

分享到:  QQ好友和群QQ好友和群
收藏收藏
回复

使用道具 举报

0

主题

23

帖子

73

积分

注册会员

Rank: 2

积分
73
沙发
发表于 2022-10-14 06:52 | 只看该作者
音乐的源文件如何下载
回复

使用道具 举报

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表