PHPackages                             digitalnature/php-ref - 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. digitalnature/php-ref

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

digitalnature/php-ref
=====================

A nicer print\_r/var\_dump alternative for PHP 5.3+

v1.3(6y ago)349723.7k↓44.5%57[18 issues](https://github.com/digitalnature/php-ref/issues)[5 PRs](https://github.com/digitalnature/php-ref/pulls)13MITPHPPHP &gt;=5.3.0

Since Aug 17Pushed 3y ago20 watchersCompare

[ Source](https://github.com/digitalnature/php-ref)[ Packagist](https://packagist.org/packages/digitalnature/php-ref)[ Docs](https://github.com/digitalnature/php-ref)[ RSS](/packages/digitalnature-php-ref/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)DependenciesVersions (4)Used By (13)

REF, or `r()` is a nicer alternative to PHP's [`print_r`](http://php.net/manual/en/function.print-r.php) / [`var_dump`](http://php.net/manual/en/function.var-dump.php) functions.

[DEMO](http://dev.digitalnature.eu/php-ref/)
--------------------------------------------

[](#demo)

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

[](#requirements)

- (server) PHP 5.3+ (5.4+ displays additional info)
- (client) Any browser, except IE 8 and lower of course

Installation using Composer
---------------------------

[](#installation-using-composer)

Add REF to your `composer.json`:

```
{
    "require": {
        "digitalnature/php-ref": "dev-master"
    }
}
```

Now tell composer to download the bundle by running:

```
$ php composer.phar update digitalnature/php-ref
```

Composer will install the bundle to the directory `vendor/digitalnature`.

Usage
-----

[](#usage)

Basic example:

```
// include the class (not needed if project runs with Composer because it's auto-loaded)
require '/full/path/to/ref.php';

// display info about defined classes
r(get_declared_classes());

// display info about global variables
r($GLOBALS);

```

To print in text mode you can use the `rt()` function instead:

```
rt($var);

```

To terminate the script after the info is dumped, prepend the bitwise NOT operator:

```
~r($var);   // html
~rt($var);  // text

```

Prepending the error control operator (@) will return the information:

```
$output = @r($var);   // html
$output = @rt($var);  // text

```

Keyboard shortcuts (javascript must be enabled):

- `X` - collapses / expands all levels
- `Ctrl` + `X` - toggles display state

To modify the global configuration call `ref::config()`:

```
// example: initially expand first 3 levels
ref::config('expLvl', 3);

```

You can also add configuration options in your `php.ini` file like this:

```
[ref]
ref.expLvl = 3
ref.maxDepth = 4

```

Currently available options and their default values:

OptionDefaultDescription`'expLvl'``1`Initially expanded levels (for HTML mode only). A negative value will expand all levels`'maxDepth'``6`Maximum depth (`0` to disable); note that disabling it or setting a high value can produce a 100+ MB page when input involves large data`'showIteratorContents'``FALSE`Display iterator data (keys and values)`'showResourceInfo'``TRUE`Display additional information about resources`'showMethods'``TRUE`Display methods and parameter information on objects`'showPrivateMembers'``FALSE`Include private properties and methods`'showStringMatches'``TRUE`Perform and display string matches for dates, files, json strings, serialized data, regex patterns etc. (SLOW)`'formatters'``array()`Custom/external formatters (as associative array: format =&gt; className)`'shortcutFunc'``array('r', 'rt')`Shortcut functions used to detect the input expression. If they are namespaced, the namespace must be present as well (methods are not supported)`'stylePath'``'{:dir}/ref.css'`Local path to a custom stylesheet (HTML only); `FALSE` means that no CSS is included.`'scriptPath'``'{:dir}/ref.js'`Local path to a custom javascript (HTML only); `FALSE` means no javascript (tooltips / toggle / kbd shortcuts require JS)`'showUrls'``FALSE`Gets information about URLs. Setting to false can improve performance (requires showStringMatches to be TRUE)`'timeout'``10`Stop execution after this amount of seconds, forcing an incomplete listing. Applies to all calls`'validHtml'``FALSE`For HTML mode only. Whether to produce W3C-valid HTML (larger code output) or unintelligible, potentially browser-incompatible but much smaller code outputSimilar projects
----------------

[](#similar-projects)

- [Kint](http://raveren.github.io/kint/)
- [dump\_r](https://github.com/leeoniya/dump_r.php)
- [Krumo](http://sourceforge.net/projects/krumo/)
- [dBug](http://dbug.ospinto.com/)
- [symfony-vardumper](http://www.sitepoint.com/var_dump-introducing-symfony-vardumper/)

TODOs
-----

[](#todos)

- Inherit DocBlock comments from parent or prototype, if missing
- Refactor "bubbles" (for text-mode)
- Correctly indent multi-line strings (text-mode)
- Move separator tokens to ::before and ::after pseudo-elements (html-mode)

License
-------

[](#license)

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity57

Moderate usage in the ecosystem

Community36

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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 ~813 days

Total

3

Last Release

2347d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d7c268d5f3e275db12d39da0f13c71a537e2618ed4bfcd6866f32576ba49d11?d=identicon)[digitalnature](/maintainers/digitalnature)

---

Top Contributors

[![digitalnature](https://avatars.githubusercontent.com/u/99317?v=4)](https://github.com/digitalnature "digitalnature (126 commits)")[![morrislaptop](https://avatars.githubusercontent.com/u/67807?v=4)](https://github.com/morrislaptop "morrislaptop (3 commits)")[![ureimers](https://avatars.githubusercontent.com/u/1671217?v=4)](https://github.com/ureimers "ureimers (2 commits)")[![joe-walker](https://avatars.githubusercontent.com/u/933773?v=4)](https://github.com/joe-walker "joe-walker (2 commits)")[![jcmarchi](https://avatars.githubusercontent.com/u/5833366?v=4)](https://github.com/jcmarchi "jcmarchi (1 commits)")[![patrioticcow](https://avatars.githubusercontent.com/u/751813?v=4)](https://github.com/patrioticcow "patrioticcow (1 commits)")[![aolin480](https://avatars.githubusercontent.com/u/1616101?v=4)](https://github.com/aolin480 "aolin480 (1 commits)")[![wycks](https://avatars.githubusercontent.com/u/875757?v=4)](https://github.com/wycks "wycks (1 commits)")[![Bukashk0zzz](https://avatars.githubusercontent.com/u/1908342?v=4)](https://github.com/Bukashk0zzz "Bukashk0zzz (1 commits)")[![insign](https://avatars.githubusercontent.com/u/1113045?v=4)](https://github.com/insign "insign (1 commits)")[![ivosabev](https://avatars.githubusercontent.com/u/103370?v=4)](https://github.com/ivosabev "ivosabev (1 commits)")

---

Tags

debugvar\_dump

### Embed Badge

![Health badge](/badges/digitalnature-php-ref/health.svg)

```
[![Health](https://phpackages.com/badges/digitalnature-php-ref/health.svg)](https://phpackages.com/packages/digitalnature-php-ref)
```

###  Alternatives

[koriym/printo

An object graph visualizer.

1452.0M2](/packages/koriym-printo)[mmucklo/krumo

KRUMO - version 2.0 of print\_r(); and var\_dump(); (with new updates)

94171.6k6](/packages/mmucklo-krumo)[leeoniya/dump-r

a cleaner, leaner mix of print\_r() and var\_dump()

12368.9k5](/packages/leeoniya-dump-r)[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)[kktsvetkov/krumo

Krumo is a debugging tool, which displays structured information about any PHP variable. It is a nice replacement for print\_r() or var\_dump() which are used by a lot of PHP developers.

8362.2k](/packages/kktsvetkov-krumo)[php-sage/sage

☯ Insightful PHP debugging assistant.

5748.2k7](/packages/php-sage-sage)

PHPackages © 2026

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