Can’t run task when there is constructor

By | July 12, 2018

I am building a component which will act as a API for a front end and was curious about something. For example if I call the url it will work without any problem. This is all in my components main controller.php file. However I want to add a constructor to define class variables to use throughout my various functions (tasks). If I then try to run a task, it will give me a 404 error saying the task can't be found. If I remove the constructor it works again.

So I guess my question is can I run a task with a constructor in the controller.php file or is it because I am targeting a specific task it won't run, which seems odd to me.