Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Multiple arguments to a task
  • Hey all,

    I'm trying to figure out how you pass multiple arguments to a Task.

    I'm running:

    php oil refine sometask:run 'some_arg'

    with the task code being

    class sometask{
        public function run($arg1){

            echo $arg1;

        }
    }

    and this runs fine.

    What I really need to have though is

    php oil refine sometask:run 'some arg'  'some arg2'

    class sometask{
        public function run($arg1,$arg2){

            echo $arg1;
    echo $arg2;
        }
    }


    which unfortunately doesn't work (no errors seem to be returned). Can someone point me in the right direction on how to handle this? 

    Thanks

  • HarroHarro
    Accepted Answer
    No problem whatsover?

    <?php
    namespace Fuel\Tasks;

    class Test
    {
        public static function run()
        {
            var_dump(func_get_args());
        }
    }

    and calling it:

    $ php oil refine test 'some arg'  'some arg2'
    array(2) {
      [0] =>
      string(8) "some arg"
      [1] =>
      string(9) "some arg2"

    Both get passed as arguments without any problem?
  • Didn't realise it was that simple. Got a little confused by the Docs :)

    Cheers.
  • I basically did exactly the same as you, so what did you change to make it work?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion