New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

adachsoft/debugger

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adachsoft/debugger

Check your logs in the console.

Source
Packagist
Version
v0.1.1
Version published
Total downloads
374
Maintainers
1
Created
Source

adachsoft/debugger

A small, framework-agnostic PHP debugger/logger that can dump variables, print backtraces and measure execution time.

It can be used directly by instantiating AdachSoft\Debugger\Debugger with your preferred LogInterface and ParserInterface, or via the global facade D / helper function d().

Requirements

  • PHP ^8.3

Installation

composer require adachsoft/debugger

Quick start (explicit instance)

use AdachSoft\Debugger\Debugger;
use AdachSoft\Debugger\Log\LogPrint;
use AdachSoft\Debugger\ParserVarDump;

$debugger = new Debugger(new LogPrint(), new ParserVarDump());

$debugger->varDump(['hello' => 'world']);
$debugger->backTrace();

Quick start (factory)

The factory provides ready-to-use presets:

use AdachSoft\Debugger\DebuggerFactory;

$debugger = DebuggerFactory::create();
$debugger->varDump('hello');

Available presets:

  • DebuggerFactory::create()
  • DebuggerFactory::createColored()
  • DebuggerFactory::createTypeWithoutValue()

Global facade (D) and helper function (d)

This package ships a global class D (in the global namespace) and a global helper function d(). They are autoloaded through Composer autoload.files, so they work after including vendor/autoload.php.

require_once __DIR__ . '/vendor/autoload.php';

d(['a' => 1, 'b' => [true, null]]);

D::useTypeOnly();
d(['a' => 1, 'b' => [true, null]]);

D::useStandard();
D::dump('standard mode', ['x' => 123]);

Timing

D::start();
usleep(100_000);
$elapsed = D::stop('sleep');

D::dump('elapsed', $elapsed);

Backtrace

D::trace();

Error handler

use AdachSoft\Debugger\Debugger;

Debugger::showAllErrors();

$debugger = D::getInstance();
$debugger->setErrorHandler();

// Any PHP warning/notice/error will be formatted and sent to the configured logger.

Logging targets

The debugger delegates output to a LogInterface implementation.

Built-in loggers (see src/Log):

  • AdachSoft\Debugger\Log\LogPrint (console output)
  • AdachSoft\Debugger\Log\LogToFile (append to a file)
  • AdachSoft\Debugger\Log\LogToServer (send to a TCP server)

Example:

use AdachSoft\Debugger\Debugger;
use AdachSoft\Debugger\Log\LogToFile;
use AdachSoft\Debugger\ParserVarDump;

$debugger = new Debugger(
    new LogToFile(fileName: __DIR__ . '/debug.log'),
    new ParserVarDump(),
);

$debugger->varDump('saved to file');

License

MIT

Keywords

debug

FAQs

Package last updated on 09 Mar 2026

Related posts