2

I have a Codeigniter project that uses Codeception for acceptance testing. I have a 'tools' controller setup in Codeigniter, which I use to store command line methods that perform various utility functions.

In this case, I'm creating a utility method that sets up the testing environment, switches databases, builds / runs the tests, etc.

I'm using the PHP function shell_exec() to run the codception commands. They're working, however when shell_exec() issues the `php codecept.phar run' command, it's not providing verbose output. It waits until all the tests are done (which takes a long time) and then spits out all the output at the end.

Is there a way to have shell_exec() print the output as it receives it?

example code:

public function run_tests() 
{ 
     $this->load->database('testing'); 
     echo shell_exec("cd ..; php codecept.phar build"); 
     echo shell_exec("cd ..; php codecept.phar run"); 
}
2
  • 2
    php.net/manual/en/function.passthru.php Commented Mar 5, 2015 at 19:36
  • excellent, works great. Post this as an answer to I can accept it! Commented Mar 5, 2015 at 19:39

1 Answer 1

2

Use passthru, which streams the output of a command directly to the response stream.

Sign up to request clarification or add additional context in comments.

1 Comment

For some reason I am losing terminal/shell color codes on passthru()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.