Download the PHP package karontek/bcons without Composer
On this page you can find all versions of the php package karontek/bcons. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download karontek/bcons
More information about karontek/bcons
Files in karontek/bcons
Package bcons
Short Description bcons is console.log for backend, it allows you to send debug data from your PHP code to the browser devtools.
License GPL-3.0-or-later
Informations about the package bcons
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
Requirements
This package requires only PHP >= 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
-
Create an account at bcons.dev
- On the 'Account' page, copy your user token.
- Navigate to the Projects page, create your project, and a token will be assigned to it. Copy this token.
-
Install the bcons browser extension.
Chromium-based browsers (Google Chrome, Microsoft Edge, Opera, Vivaldi, Brave, etc.)
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.
-
Install the PHP package
composer require karontek/bcons
Usage
Instantiate the bcons class.
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) to send messages and view them on your bcons console.
All methods can be chained:
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 page) or through the browser extension devtools panel. They will also appear in your browser's devtools console.
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 and groupCollapsed 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
togroup22
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 classesred
,orange
,amber
,yellow
,lime
,green
,emerald
,teal
,cyan
,sky
,blue
,indigo
,violet
,purple
,fuchsia
,pink
,rose
,stone
,neutral
,zinc
,gray
andslate
(see Tailwind Color Palette).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 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 theclr
method. - The debug, info, dir and dirxml methods are all aliases of log.
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.
-
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.