Skip to main content

Posts

Showing posts from November, 2016

Downgrade Laravel 5.3 to 5.2

I've just downgrade Lv 53 to 52. Here some notes: - update composer.json: laravel 5.3 to 5.2 + php 5.6.? to 5.5.9 + remove passport and related if use it. (OAuth json build in lv53 instead of JWT) + Copy default file in App\Http\MiddleWare and/or  \Provider. + Update User.php model. + Update app, remove Notificable(?), and other class (don't remember) - Merge all route 5.3 web.php, api.php console.php to routes.php in App\Http\ in Lv 5.2 => run composer update. If error, trace to class and config/ to update. I'm too lazy to downgrade Xampp to php5.5 so still run on php 5.6 just fine. I install 2 version of Xampp on diff location and cant start it dependence. Still not try to run on Xampp php5.5. On Windows server I've try to install 2 version of xampp but no luck because may be some service of xampp can not use for both version. So I have to unistall old xampp and clean be4 install new version. I will write some note how to remove old Xampp service

Laravel create command console.

Create console:      php artisan make:console CrawDataRx Create console and command:       php artisan make:console CrawlDatRx --command=cron:crawlDataRx Or You can create console only and then edit this line in Console class: class CrawlDataRx extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'cron:crawlDataRx'; ... We can use Model in Console class and code like in Controller. In handle() function we can write logic here or just call self::function_name() or $this->function_name() Output to command (git-bash or cmd): /** * Execute the console command. * * @return mixed */ public function handle() { $this->info('Start crawling...'); self::crawlUserData(); $this->info('Crawl done.'); }

Cronjob Windows using TaskScheduler

In previous note about cronjob auto open a web page we used a simple batch script to call browser open url. In this note I implement a simple cronjob using TaskScheduler and batch script call a php.exe command. My project use laravel command console. If it is raw php file we can run by direct execute filename. A note from other site:  https://laracasts.com/discuss/channels/general-discussion/running-schedulerun-on-windows My cron_crawl_data.bat: $ cat ~/Desktop/SadHill/cron_download_Data_rx.bat cd e:\setin\xampp_56\htdocs\XP_Project\MyProject\ E:\setin\xampp_56\php\php.exe artisan cron:crawlData 1>> NUL 2>&1 Task Scheduler: A mentioned in a note (I too lazy to search history to get link), you may be need open TaskScheduler from Windows start > Accessories > systemtools > ... instead of call from Right click My Computer. After add task you have to refresh to see newly added task. I too lazy to test cron run or not. May be using a test like open web