PHPackages                             squirrelphp/debug - 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. squirrelphp/debug

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

squirrelphp/debug
=================

Debug functionality: create exception with origin call data and sanitizing function arguments and other data for output

v2.1(4y ago)16.0k↓50%5MITPHPPHP &gt;=8.0

Since Jul 10Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/squirrelphp/debug)[ Packagist](https://packagist.org/packages/squirrelphp/debug)[ Docs](https://github.com/squirrelphp/debug)[ RSS](/packages/squirrelphp-debug/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (10)Used By (5)

Squirrel Debug
==============

[](#squirrel-debug)

[![Build Status](https://camo.githubusercontent.com/ad1c31d2d8059fa914911874018370a8b088bbaf1a3cc159841ea17496621756/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f737175697272656c7068702f64656275672e737667)](https://travis-ci.com/squirrelphp/debug) [![Test Coverage](https://camo.githubusercontent.com/cc64fef9129a50fb0f98314af7a77d3cfbedc2b785a96f237e87da6525c482b1/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f32346135646164373930643230313438653130612f746573745f636f766572616765)](https://codeclimate.com/github/squirrelphp/debug/test_coverage) [![PHPStan](https://camo.githubusercontent.com/65e2c93fbe63f94af93706ba48d15eafa85a0cd4ff0c5aeea712b4da080d7545/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230382d737563636573732e7376673f7374796c653d666c61742d726f756e64266c6162656c3d7068707374616e)](https://camo.githubusercontent.com/65e2c93fbe63f94af93706ba48d15eafa85a0cd4ff0c5aeea712b4da080d7545/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230382d737563636573732e7376673f7374796c653d666c61742d726f756e64266c6162656c3d7068707374616e) [![Packagist Version](https://camo.githubusercontent.com/9e9ccc01b6e6f86656f1f27bb59fb31f0a24b612410b1c88f33eaaf7c9702841/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737175697272656c7068702f64656275672e7376673f7374796c653d666c61742d726f756e64)](https://packagist.org/packages/squirrelphp/debug) [![PHP Version](https://camo.githubusercontent.com/d03f64998164edcf46121e211c906edf0e643ccad05904ae0d89062cc0ec022a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f737175697272656c7068702f64656275672e737667)](https://packagist.org/packages/squirrelphp/debug) [![Software License](https://camo.githubusercontent.com/4f9c8f8c009336d7177cf697d694e2e763e5e707f1a6224ab0d295465eadffbd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d737563636573732e7376673f7374796c653d666c61742d726f756e64)](LICENSE)

Provides backtracing functionality to enable libraries to find the true origin of a problem (as opposed to where it becomes a problem) even if it is not know in what context the library/component is being used, and includes an exception base class for adding the origin data when throwing exceptions. Also provides an easy way of dumping debug data and function arguments in a shortened form. This is a helper library created for the other squirrel libraries, but it can be useful in any library or application.

Installation
------------

[](#installation)

```
composer require squirrelphp/debug

```

Finding the origin method call
------------------------------

[](#finding-the-origin-method-call)

When using libraries and abstractions it often is not relevant where a problem occurs (leading to an exception or warning), but where in the application the relevant call was made to the library/component that then causes the problem.

`Squirrel\Debug\Debug::findOrigin` goes through the debug backtrace and finds the relevant method call that lead to the current point in the application. You can (and should) provide classes/interfaces and namespaces it should ignore (to go back further and find the method call that preceded it). This method returns an Origin object which includes the file and line of the origin together with the method call (and its arguments).

Creating an OriginException
---------------------------

[](#creating-an-originexception)

`Squirrel\Debug\Debug::createException` uses `Squirrel\Debug\Debug::findOrigin` to find the origin of the current problem and then creates an OriginException (which is an exception that includes the additional information about the origin). You should create your own exception classes which extend OriginException so you can then handle specific problems in your application/library.

Sanitize data and arguments
---------------------------

[](#sanitize-data-and-arguments)

Dumping some form of debug data is a common requirement, but often is more troublesome than expected. When dumping data with objects in modern frameworks, the resulting dump can be so big that it exceeds the PHP memory limit and makes problems harder to spot rather than easier. Also, binary data in the dump can make it impossible to see anything useful.

`Squirrel\Debug\Debug::sanitizeData` and `Squirrel\Debug\Debug::sanitizeArguments` create small dumps without including object data: they only include the class name for objects, they show binary data as hex strings, and they show the resource type for resources. Arrays are shown in PHP array notation, so the output is easy to read for PHP developers. All other data types are shown fully (string, int, float, bool, null).

`Squirrel\Debug\Debug::sanitizeArguments` is used internally by `Squirrel\Debug\Debug::createException` to show the origin call that lead to an exception, which is why the functionality was added to this library.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance43

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~110 days

Recently: every ~2 days

Total

9

Last Release

1618d ago

Major Versions

v0.5.5 → v1.02021-12-04

v1.0 → v2.02021-12-11

PHP version history (3 changes)v0.5PHP ^7.2

v0.5.2PHP &gt;=7.2

v1.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cd200dc74af2d77e8c480000a7e3bab0b8a98fae4b399d306b3d332354f8177?d=identicon)[iquito\_ch](/maintainers/iquito_ch)

---

Top Contributors

[![iquito](https://avatars.githubusercontent.com/u/973653?v=4)](https://github.com/iquito "iquito (27 commits)")

---

Tags

phpdebugexception

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/squirrelphp-debug/health.svg)

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

###  Alternatives

[jbzoo/jbdump

Script for debug and dump PHP variables and other stuff. This tool is a nice replacement for print\_r() and var\_dump() functions.

211.1M3](/packages/jbzoo-jbdump)[h4cc/phpqatools

A meta composer package for PHP QA Tools.

6418.6k1](/packages/h4cc-phpqatools)[kuria/error

Makes handling and debugging PHP errors suck less

1920.0k2](/packages/kuria-error)[thehocinesaad/laravel-error-ai

This package adds Ask AI button to the error page.

2214.4k](/packages/thehocinesaad-laravel-error-ai)

PHPackages © 2026

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