Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Oil task through rest controller, response contains cli:write
  • Hello, 
    I have an application that through ajax calls a task.
    It goes like this, webpage->rest controller->system( task)-> response -> webpage.

    The problem is that the task has some "Cli::write(stuff)" that get somehow inside the response of the rest controller...
    I cannot get rid of them (I don't want to stop using Cli::write) even if I return $this->response(array('no'=>'thing');

    What on earth is happening? I checked out the Rest core code. It seems ok. If this was C I would say that something is writing in somebody's else memory...
    :-) 
    Thank you
  • Cli::write() writes, like echo does, to the output device. Normally for a task that is the console, but if you call it interactively (or through a rest service), the writes will be part of the output.

    You can remove this by wrapping the call to the task in output buffering, using ob_start() and ob_clean(), this will buffer and remove any console output the task produces.
  • Thank you! That did the trick!

Howdy, Stranger!

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

In this Discussion