当前位置:网站首页>Implementation of timed tasks in laravel framework
Implementation of timed tasks in laravel framework
2022-06-28 01:36:00 【I want a little cute】
Generate command
You can use Artisan command make:command To create a new command .make:command The order will be in app/Console/Commands Create a new command class in the directory . If the directory does not exist , It will be the first time you run make:command Automatically create on command . The generated command will contain all the attributes and methods that exist by default in the command .
————————————————
Original author :Laravel China Community documentation :《Laravel 8 Chinese document (8.x)》
From the link :https://learnku.com/docs/laravel/8.x/artisan/9387#2fe472
Copyright notice : The copyright of translated documents belongs to the translator and LearnKu Community owned . Reprint
php artisan make:command SendEmails 
Code :
<?php
namespace App\Console\Commands;
use App\Models\exam1\Pin;
use Illuminate\Console\Command;
class SendEmail extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'sendEmail';
/**
* The console command description.
*
* @var string
*/
protected $description = 'sendEmail';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
Pin::insert([
'uid'=>3,
'desc'=>' describe ',
'sid'=>11
]);
}
}stay app/Cosole/Kernel.php

<?php
namespace App\Console;
use App\Console\Commands\SendEmail;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
protected $commands=[
SendEmail::class
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('sendEmail')->everyMinute();
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}Run the command :
php artisan schedule:workeffect :

边栏推荐
- Informatics Olympiad all in one 1359: enclosed area
- 药物发现综述-03-分子设计与优化
- 单晶炉导电滑环的应用范围和作用是什么
- 有监督、无监督与半监督学习
- 现在网上开股票账户安全吗?选择上市券商,最快8分钟开户成功
- Intensive reading of transformer thesis paragraph by paragraph
- Neural network of zero basis multi map detailed map
- plot_ Model error: pydot and graphviz are not installed
- Arrays. Aslist() pit
- 无人机专用滑环定制要求是什么
猜你喜欢

Réseau neuronal pour la solution détaillée Multi - diagrammes de fondation zéro

Form forms and form elements (input, select, textarea, etc.)

Deep parsing of kubernetes controller runtime

Huawei partners and Developers Conference 2022 | Kirin software cooperates with Huawei to jointly build the computing industry and create a digital intelligence future
Latest MySQL advanced SQL statement Encyclopedia

Deploy a mongodb single node server locally, enable auth authentication and enable oplog

Redis configuration and optimization of NoSQL

Taro---day1---搭建项目

.mp4视频测试地址

Drug interaction prediction based on learning size adaptive molecular substructure
随机推荐
药物发现综述-02-分子性质预测
awk注意的几个问题
What is the application scope and function of the conductive slip ring of single crystal furnace
Is it safe for Xiaobai in the stock market to open an account on the Internet?
How to understand query, key and value in transformer
The contents of the latex table are left, middle and right
如何阅读一篇论文
哪个证券炒股开户佣金是最便宜,最安全的
药物发现综述-03-分子设计与优化
Acwing game 57 [unfinished]
Is it safe to open an account for mobile stocks? Where can I open an account for buying stocks?
Arrays.asList()坑
PV操作原语
Esxi based black Qunhui DSM 7.0.1 installation of VMware Tools
【无标题】
吸顶方案1
lodash实现防抖和节流功能及原生实现
模块化开发
Introduction to memory model of JVM
LMSOC:一种对社会敏感的预训练方法