aneeshsudhakaran / laravel5.3demo

laravel 5.3 Demo for Multiauth with user and admin table
GNU General Public License v3.0
16 stars 13 forks source link

Cron job in Laravel 5.3 #1

Open aneeshsudhakaran opened 8 years ago

aneeshsudhakaran commented 8 years ago

How we can create Cronjob in Laravel 5.3

aneeshsudhakaran commented 8 years ago

Step 1 : Create php artisan make:command { CronFileName} --command={cron:name} Eg: php artisan make:command StoreDealemail --command=storedeal:email

Step 2 : Open app\Console\Commands{CronFileName} Update : app\Console\Commands{CronFileName} `protected $signature ={cron:name} // same as {cron:name}

protected $description ={Description }; // Description about cron public function handle() { // Write Code here } `

Step 3 :Open app\Console\kernel.php

add protected $commands = [ // Commands\{CronClasName}::class, ]; protected function schedule(Schedule $schedule) { // $schedule->command('inspire') // ->hourly(); $schedule->command('storedeal:email')->daily(); // add cron command with interval }

Step 4 : Test Conjob Run : php artisan {cron:name} eg: php artisan storedeal:email