Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a GET to a certain URL every 5 mins in Laravel

I'm using Laravel. I'm trying to make a GET to a certain URL (http://localhost/user/check_token) every 5 mins.

I'm thinking:

  • Create a route http://localhost/user/check_token
  • Write a Python script to make a GET to that route
  • Configure a cron job to trigger that script every 5 mins

But I'm curious if we can achieve this in Laravel itself.

Can we declare a route and make it self executed, or something like that?

Is my Python solution is the best practice for this kind of task?

like image 214
code-8 Avatar asked Dec 14 '22 03:12

code-8


1 Answers

Laravel way is:

  1. Create console command
  2. Run scheduler

Command is just a PHP class, so you can use all power of Laravel in it.

like image 133
Alexey Mezenin Avatar answered Mar 17 '23 03:03

Alexey Mezenin