rame0 / chromephp
Log variables to the Chrome console (via Chrome Logger Google Chrome extension).
5.0.3-patch1
2021-05-17 16:29 UTC
Requires
- php: >=7.4.0
- ext-json: *
This package is auto-updated.
Last update: 2024-10-17 23:43:23 UTC
README
ChromePhp is a PHP library for the Chrome Logger Google Chrome extension.
This library allows you to log data to the Chrome console.
Requirements
- PHP 7.4 or later
Installation
- Install the browser extension from: https://chrome.google.com/extensions/detail/noaneddfkdjfnfdakjjmocngnfkfehhd
- Click the extension icon in the browser to enable it for the current tab's domain
- Install ChromePhp
It's not recommended to use this library on production!
Install as dev dependency:
composer require --dev rame0/chromephp
Install as prod dependency:
composer require rame0/chromephp
Log some data
// First require autoload require __DIR__ . '/vendor/autoload.php'; $logger = new ChromePhp();
Log
$logger->log('Some log message'); $logger->log('Some other log message');
Result
Warning
$logger->warn('Some warning'); $logger->warn('Some other warning');
Result
Error
$logger->error('Some error'); $logger->error('Some other error');
Result
Table
$table = []; for ($i = 0; $i < 5; $i++) { $row = []; for ($c = 1; $c < 3; $c++) { $row['Col ' . $c] = $i; } $table[] = $row; } $logger->table($table);
Result
Exception
$ex = new InvalidArgumentException('Some exception!'); $logger->exception($ex); try{ new PDO('asdf'); }catch (PDOException $ex){ $logger->exception($ex); }
Result
More information can be found here: http://www.chromelogger.com