In a normal php-script you can do this:
print "run in 3\n"
sleep(1);
print "run in 2\n";
sleep(1)
And so on... You get the output and wait a second and you get the next output.
So now i run a script with slimframework on cli with:
$env = \Slim\Http\Environment::mock([
'REQUEST_METHOD' => 'GET',
'HTTPS' => true,
'SERVER_NAME' => 'www.domain.tld',
'REQUEST_URI' => '/cli_action'
]);
$settings['environment'] = $env;
...
$app->run();
It works fine and do the job ( send emails ). But the first time i get an output on the cli is when the script ends. Is there an elegant solution to get an output ( log-messages ) while running?
Thanks for help.
Thomas
Slim uses output buffering by default. When instantiating a new \Slim\App object disable output buffering by setting outputBuffering
to false
:
$settings ['outputBuffering'] = false;
$app = new \Slim\App($settings);