We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

CLI task with optional parameters

Hi, Is it currently possible to implement taks which expects any number of parameters but will work even if no parameters provided?

Currently it returns 'argument must be of type array' error if no params passed and task looks like that:

public function myTaskAction(array $params)

I see the only way to store arguments['params'] in di, is that the only option?



1.1k
Accepted
answer

You can pass an empty array

edited Jul '15

Thank you, it works.

PS. Also after asking I realized that I could wrap cli call in shell script to make task calls look more concise and set defaults there.