What Is bcons and What Does It Do for PHP Debugging?

Updated

bcons is a PHP debugging tool that displays debug data in your browser instead of in server logs. It has two stated goals: display PHP messages in a clear, organized way, and implement the browser Console API for PHP so you can debug PHP code more efficiently. It is relevant to you if you currently rely on error_log() and server log files to trace variables, errors, or request data in PHP.

What bcons shows you

According to the site, bcons is a companion for debugging tasks such as logging messages or tracking the values of variables at set points in your code. It also displays:

  • Errors and warnings
  • Session data
  • Cookies
  • Payload information
  • Log messages and variable values

Any warning or error in your code is reported to the bcons console with the source file name, line number, and stack trace.

How it works

bcons sends an HTTP header that instructs the PHP code to enable the sending of error and debugging messages to the bcons console. The console itself is available in two forms:

  • A browser devtools extension
  • The bcons website

So the flow is: your PHP code emits messages, the header mechanism routes them, and you read them in a browser-based console rather than in a log file.

The problem it replaces

The site frames bcons as an alternative to error_log() and cryptic server logs. Its example shows a raw FastCGI stderr dump where a single request produces a wall of PHP message: lines covering the current user, checkout request, payload array, session array, cookies array, billing status, and a redirect — all as undifferentiated text.

bcons presents that same kind of data in separate tabs, with easy access to the time, domain, source file, and trace data. In other words, the information is the same, but it is organized by type and source instead of concatenated into one log stream.

What the console experience is like

The site notes that all bcons consoles on its page are live and clickable, and that Ctrl+click on any message element copies it to the clipboard. That matters for two practical reasons:

  • You can inspect real message structure before deciding whether the format fits your workflow.
  • Copying a message element gives you a clean way to move a specific error or variable dump into a bug report or chat.

Where it fits in a debugging workflow

Use bcons when you want per-request visibility into errors, warnings, variable values, session, cookies, and payload without tailing a log file. The source file, line number, and stack trace attached to each warning or error make it suited to locating the origin of a problem rather than just confirming that one occurred.

The site describes setup as three steps, but the input material does not include the step details, so the exact installation and configuration procedure is not covered here. Check the bcons site for the current setup instructions before assuming a particular integration method.