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

wrong cli docs on params passing?

From the CLI docs (https://docs.phalcon.io/en/latest/reference/cli.html) it seems like the array I have to pass to Console::handle() is in this format:

array(
  "task" => "email",
  "action" => "main",
  "params" => array(
    0 => "1"
    1 => "test"
  ),
)

But the second parameter is never passed to the task, and the first parameter is of type array. What i'm actually using is this format:

array(
  "task" => "email",
  "action" => "main",
  0 => "1",
  1 => "test",
)

using this code:

$arguments = array();
foreach ($argv as $k => $arg)
{
    if ($k == 1)
        $arguments['task'] = $arg;
    else if ($k == 2)
        $arguments['action'] = $arg;
    else if ($k >= 3)
        $arguments[] = $arg;
}

Are the docs referring to an old way of passing parameter? I'm using 1.3.0 atm

Looking at the 2.0 router.zep it seems like the "task" and "action" array keys are unset leaving the whole array as params.



3.2k
Accepted
answer

The tests uses the same format, so here's my pull request to fix the docs

https://github.com/phalcon/docs/pull/360



8.6k

This was fixed for 1.3.1? Because it behaves the same(passes a string instead of array).



8.6k

Okay, I found out that you need to use it this way:

public function testAction( $param1, $param2 ) {