Summary of how to use the task scheduling console in Laravel, laravelconsole
Use Cases: analyze data (logs)
Php artisan make: console your command Class Name
Example:
php artisan make:console Check
A Check. php file has been generated under the \ app \ Console \ Commands directory
<?phpnamespace App\Console\Commands;use Illuminate\Console\Command;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() { // }}
You can change $ signature to the command name you want.
protected $signature = 'check';
At this time, it cannot be called in the console. You need to register it in Kernel. php.
protected $commands = [ 'App\Console\Commands\Check'];
You can use this command on the console.
php artisan check
Comment: It seems useless, because php itself does not need the Laravel framework to use CLI.