Welcome Guest, Not a member yet? Register   Sign In
Best practice for writing code for cron *and* interactive use
#1
Question 

What is considered best practice for CI4 when it comes to code/functionality that could be invoked either by a cron script, or interactively at the press of a button by the user?

I guess it's something along the lines of putting all the "shared code" in regular models, controllers, and views, and then utilizing the model and controller in a stand-alone PHP script but adding CLI output in that particular script?

-joho
Reply
#2

You can use both HTTP controllers and create commands for the console like make:migrate. I am currently using the URL launch solution via wget --quiet htttp://site.io/cron/12KAW4OA25
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#3
Question 

OK. So this is the way to go if I want to have a minimum of duplicate code? Since it needs to be available via a normal view/model/controller setup, but also via a cron script (where the "user" is obviously unauthenticated), I figured it'd be more work than that.

-joho
Reply




Theme © iAndrew 2016 - Forum software by © MyBB