PHPackages                             karontek/bcons - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. karontek/bcons

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

karontek/bcons
==============

bcons is console.log for backend, it allows you to send debug data from your PHP code to the browser devtools.

v1.0.27(1y ago)0308GPL-3.0-or-laterPHPPHP &gt;=5.3.0

Since Mar 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/bcons-open-source/bcons-php-connector)[ Packagist](https://packagist.org/packages/karontek/bcons)[ RSS](/packages/karontek-bcons/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (29)Used By (0)

bcons PHP connector
===================

[](#bcons-php-connector)

This package enables you to send messages from your PHP code to the bcons console.

It allows you to perform debugging tasks, such as logging messages or the values of variables at set points in your code, displaying errors and warnings, and tracking session, cookies, and payload data.

Screenshots
===========

[](#screenshots)

[![bcons console in a devtools panel](https://camo.githubusercontent.com/3647d7049f02e7cdef449105c29054a09e33f561fe425b5192d1ec33ddb9dd2f/68747470733a2f2f62636f6e732e6465762f696d672f62636f6e7353637265656e73686f74317468756d622e706e67)](https://bcons.dev/img/bconsScreenshot1.png) [![bcons messages shown in the devtools console](https://camo.githubusercontent.com/dd23f6b2ba66bda498e5082006742cec6f095600e478e2fb315e658b3939cdc9/68747470733a2f2f62636f6e732e6465762f696d672f62636f6e7353637265656e73686f74327468756d622e706e67)](https://bcons.dev/img/bconsScreenshot2.png) [![Warning messages](https://camo.githubusercontent.com/092cade2279188674b30a5ea3bcbdb6248e251443f00f0b0f7bb5599c17213d2/68747470733a2f2f62636f6e732e6465762f696d672f62636f6e7353637265656e73686f74337468756d622e706e67)](https://bcons.dev/img/bconsScreenshot3.png) [![Error messages](https://camo.githubusercontent.com/8e7a701e085c3279840eb364d9fc5eb597956efba615877b64d93d35cc50d60c/68747470733a2f2f62636f6e732e6465762f696d672f62636f6e7353637265656e73686f74347468756d622e706e67)](https://bcons.dev/img/bconsScreenshot4.png) [![Payload sent to the server](https://camo.githubusercontent.com/9b6b99bec5d1f0489697db263bda043bfd299d442403a05b418e49608be577b8/68747470733a2f2f62636f6e732e6465762f696d672f62636f6e7353637265656e73686f74357468756d622e706e67)](https://bcons.dev/img/bconsScreenshot5.png) [![Session data](https://camo.githubusercontent.com/9e6cbcc69b05f6a96af0818b832d62a49ced4211a5e52dbc0fa68523aa7bb0d1/68747470733a2f2f62636f6e732e6465762f696d672f62636f6e7353637265656e73686f74367468756d622e706e67)](https://bcons.dev/img/bconsScreenshot6.png) [![Cookies data](https://camo.githubusercontent.com/6bacb41ce65f563cddab65ed49b751912f7ed61fb22fd56acc187da918b76a19/68747470733a2f2f62636f6e732e6465762f696d672f62636f6e7353637265656e73686f74377468756d622e706e67)](https://bcons.dev/img/bconsScreenshot7.png)

Requirements
------------

[](#requirements)

This package requires only PHP &gt;= 5.3.3, allowing its use in legacy code (where it is most needed 😅).

You will also need a bcons account (there is a 'free forever' plan for 1 user and 1 project) and the free bcons browser extension.

Setup instructions
------------------

[](#setup-instructions)

1. Create an account at [bcons.dev](https://bcons.dev)

    1. On the 'Account' page, copy your user token.
    2. Navigate to the *Projects* page, create your project, and a token will be assigned to it. Copy this token.
2. Install the bcons browser extension.

    [Chromium-based browsers (Google Chrome, Microsoft Edge, Opera, Vivaldi, Brave, etc.)](https://chromewebstore.google.com/detail/bcons-consolelog-for-back/ccdpnjompopbichhdoejnbmjomcnaccj)

    [Firefox](https://addons.mozilla.org/firefox/addon/bcons-backend-debug-helper/)

    After installation, click on the extension icon in your browser and select *Options*. Enter your user token. The browser extension adds a *Bcons-User* header to every request made to the domains defined in your project, using your user token. This enables the server code to send any debug messages generated by that request only to you.

    Note for Firefox users: by default, the extension won't be allowed to work on all sites. To enable it, go to the 'Add-ons and themes' menu section, click on the bcons extension, then on the 'Permissions' tab, and check the 'Access your data for all websites' option.
3. Install the PHP package

    `composer require karontek/bcons`

Usage
-----

[](#usage)

Instantiate the bcons class.

```
use Karontek\Bcons\Bcons;

$console = new Bcons('your project token');
```

When the bcons class is instantiated, it automatically sends debug messages including the request data payload, current session data, and cookies sent.

It will also send warning and error messages for every warning and error raised by PHP.

But the true power of bcons is unlocked with the ability to send your own messages. Use the log, warn, error methods (or any method of the [Console API](https://developer.mozilla.org/en-US/docs/Web/API/console)) to send messages and view them on your bcons console.

```
$console->log($currentUserData);
$console->warn("Zip code not available for user $userId");
$console->error("No user with id $userId found");
```

All methods can be chained:

```
$console->group('User info')->log($userData)->warn('No zip code available')->groupEnd();
```

Where are these messages displayed?
-----------------------------------

[](#where-are-these-messages-displayed)

Messages are displayed in the bcons console, which you can access via the bcons website (log in and navigate to the [Console](https://bcons.dev/console) page) or through the browser extension devtools panel. They will also appear in your browser's devtools console.

Console API support notes
-------------------------

[](#console-api-support-notes)

- All methods that accept data can receive multiple parameters. Unless any of the parameters is an array/object, bcons will concatenate all values and show them as a single string, mimicking the behavior of the devtools console.
- The [group](https://developer.mozilla.org/en-US/docs/Web/API/console/group_static) and [groupCollapsed](https://developer.mozilla.org/en-US/docs/Web/API/console/groupcollapsed_static) methods accept a second parameter that will be used as the CSS class name for the `details` element used to display the group data.

    Classes `group1` to `group22` are predefined in the bcons console with optimized colors for light and dark themes (you can also pass just a number between 1 and 22). They are also available with the named classes `red`, `orange`, `amber`, `yellow`, `lime`, `green`, `emerald`, `teal`, `cyan`, `sky`, `blue`, `indigo`, `violet`, `purple`, `fuchsia`, `pink`, `rose`, `stone`, `neutral`, `zinc`, `gray` and `slate` (see [Tailwind Color Palette](https://tailwindcolor.com)).

    Colored groups are exclusive to the bcons console. When a colored group is displayed in the devtools console, it appears as a regular group.
- In the devtools console, a call to [clear](https://developer.mozilla.org/en-US/docs/Web/API/console/clear_static) clears the console and displays a `Console cleared` message. The bcons clear method accepts an optional boolean parameter; if set to false, that message is not displayed. You can also use the `clr` method.
- The [debug](https://developer.mozilla.org/en-US/docs/Web/API/console/debug_static), [info](https://developer.mozilla.org/en-US/docs/Web/API/console/info_static), [dir](https://developer.mozilla.org/en-US/docs/Web/API/console/dir_static) and [dirxml](https://developer.mozilla.org/en-US/docs/Web/API/console/dirxml_static) methods are all aliases of [log](https://developer.mozilla.org/en-US/docs/Web/API/console/log_static).

Extra functions
---------------

[](#extra-functions)

We have added some extra functions for a better debugging experience:

- clog: this function behaves like a regular log() call but displays the content in any of the 22 colors available for the group() function. Useful when you have many messages and want to emphasize one.

    ```
    for ($x = 1; $x < 23; ++$x)
      $console->clog($x, "Message with color $x");
    ```

    [![](https://camo.githubusercontent.com/bf07f5a2ec6d935d52e669ae800bd63f0e46a24825d42f930071fe3a2a5f36c2/68747470733a2f2f62636f6e732e6465762f696d672f636c6f674c696768742e706e67)](https://camo.githubusercontent.com/bf07f5a2ec6d935d52e669ae800bd63f0e46a24825d42f930071fe3a2a5f36c2/68747470733a2f2f62636f6e732e6465762f696d672f636c6f674c696768742e706e67)
- clr: clears all console panels without showing any message.
- ping: sometimes we just need to know that our script has reached a certain point. This function does just that: it displays the file name and line number, consuming little vertical space. You can add an optional caption.

    ```
    $console->ping('Begin checkout process');
    ```

    [![](https://camo.githubusercontent.com/ac9acb9bdab15445644f01ab64d2bc428e18397dfc897f9bfb3c88926611096f/68747470733a2f2f62636f6e732e6465762f696d672f70696e674c696768742e706e67)](https://camo.githubusercontent.com/ac9acb9bdab15445644f01ab64d2bc428e18397dfc897f9bfb3c88926611096f/68747470733a2f2f62636f6e732e6465762f696d672f70696e674c696768742e706e67)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~10 days

Recently: every ~37 days

Total

28

Last Release

526d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5dd4020cc59908350f72d74086baa81990305643722841f4bd6e12519f1fc43d?d=identicon)[bcons](/maintainers/bcons)

---

Top Contributors

[![bcons-open-source](https://avatars.githubusercontent.com/u/161582597?v=4)](https://github.com/bcons-open-source "bcons-open-source (59 commits)")[![alvaro-calleja](https://avatars.githubusercontent.com/u/138875983?v=4)](https://github.com/alvaro-calleja "alvaro-calleja (1 commits)")

### Embed Badge

![Health badge](/badges/karontek-bcons/health.svg)

```
[![Health](https://phpackages.com/badges/karontek-bcons/health.svg)](https://phpackages.com/packages/karontek-bcons)
```

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
