1

I'm building a cache regeneration thing and for debugging I'd need to see every echo call as soon as it's called. I use PHP.

So basically when I call the thing, it loops on several objects, check for cached versions and outputs a success or failure message (on debug mode).

I'd need to be able to get that live output when calling the page using curl for example.

I've played a little with the ob_ PHP functions but nothing seems to work.

ob_start();
echo '[X] Failed to find a location using geocoder for: ' . $searchString . " STATUS: $response->status\n";
ob_end_flush();

But I'm not sure that I fully understood how that works.

As the web server I'm using nginx with php-fpm.

Any suggestions?

Thanks!

1 Answer 1

1

I've had good luck using the flush method. This attempts to push current output all the way to the browser. Keyword is "attempts." The biggest issue with ob_ functions and flush is that the browser has security features to sometimes not render this information until the page is finished loading. This is for security purposes, so I've read.

Command would be

echo $yourvar
flush();

An alternate solution would be to run your php script through the command line/terminal. The terminal doesn't have security features that hold off on displaying data as it comes through. When I run scripts to update databases, I typically run them through the terminal so I can see output as it comes without relying on the browser to let it through.

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

Comments

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.