Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

wrong cli docs on params passing?

From the CLI docs (http://docs.phalconphp.com/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.



2.5k
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



4.8k

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



4.8k

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

public function testAction( $param1, $param2 ) {