PHPackages                             swow-cloud/xr - 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. swow-cloud/xr

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

swow-cloud/xr
=============

Lightweight debug server utility.

0.1.3(4y ago)04Apache-2.0PHPPHP &gt;=8.0

Since Jan 10Pushed 4y agoCompare

[ Source](https://github.com/swow-cloud/xr)[ Packagist](https://packagist.org/packages/swow-cloud/xr)[ RSS](/packages/swow-cloud-xr/feed)WikiDiscussions 0.1 Synced 1mo ago

READMEChangelogDependencies (8)Versions (5)Used By (0)

XR
==

[](#xr)

> 🔔 Subscribe to the [newsletter](https://newsletter.chevereto.com/subscription?f=gTmksA6763vPCG763763kYCOTgWu6Kx4BPohVDY97aHddrqis6B763cHay8dhtmMKlI6r3vUfGREZmSvDNNGj3MlrRJV7A) to don't miss any update regarding Chevere.

[![XR](asset/icon.svg)](asset/icon.svg)

    Crocanty.mp4    🦄 [View demo](https://user-images.githubusercontent.com/20590102/153045551-619c74cc-c4ae-41da-b7b6-bd8733e623a2.mp4)

[![Code size](https://camo.githubusercontent.com/65762c79a03dc6f997e3ad938d57fe6720f1b61192263cfaf3941d92f9c91aab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f636865766572652f78723f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/65762c79a03dc6f997e3ad938d57fe6720f1b61192263cfaf3941d92f9c91aab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f636865766572652f78723f7374796c653d666c61742d737175617265) [![Apache-2.0](https://camo.githubusercontent.com/437b1e74ce603ee0a7747dd71495eab13c5b827823abcc204e01101f30a9b9b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636865766572652f78723f7374796c653d666c61742d737175617265)](LICENSE)

[![Quality Gate Status](https://camo.githubusercontent.com/e904c2b195abb73e4241908fd998640d13ee9743000ab1e1745bba12c7474c2d/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7872266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=chevere_xr) [![Maintainability Rating](https://camo.githubusercontent.com/96e6fc39a088a9d3d2ea77d526c740aad7e3cad7221cfe82785910b59792a304/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7872266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/dashboard?id=chevere_xr) [![Reliability Rating](https://camo.githubusercontent.com/4be249d8ab6eee9f8fa21c093b6f370a9baed7c17676c1eac337c43c6d2cf3f0/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7872266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/dashboard?id=chevere_xr) [![Security Rating](https://camo.githubusercontent.com/4eca6fd0a35725d87c4c4f1fda040108e6d3f5591590450d4f01fbc5f0fcdb33/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7872266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/dashboard?id=chevere_xr) [![Coverage](https://camo.githubusercontent.com/f9f1605d7150428ebe3587abcb3703509c460c81950b1520d17c0d78866ecb14/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7872266d65747269633d636f766572616765)](https://sonarcloud.io/dashboard?id=chevere_xr) [![Technical Debt](https://camo.githubusercontent.com/3f6dc62ac770c37570ebbc084b0f5a2cf068eb0235f9c0924f58c5804ce4d7da/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7872266d65747269633d7371616c655f696e646578)](https://sonarcloud.io/dashboard?id=chevere_xr) [![CodeFactor](https://camo.githubusercontent.com/9f6cc211dd56baaba3a9dcfa9648eb924ecd3bdbacd5fddf23b41b345fcdbecc/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f636865766572652f78722f6261646765)](https://www.codefactor.io/repository/github/chevere/xr) [![Codacy Badge](https://camo.githubusercontent.com/fb86d47fcdf2e64bba4002fa62bfe4b18902c882a570b51a0384914b1d01e100/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3839633634643137626536383438313862323164343463363538633733356430)](https://www.codacy.com/gh/chevere/xr/dashboard)

XR is a dump debug server utility for PHP. No extras required, debug your PHP code anywhere.

 [![XR light](.screen/xr-0.1.3-light-welcome.png)](.screen/xr-0.1.3-light-welcome.png) [![XR light](.screen/xr-0.1.3-dark-welcome.png)](.screen/xr-0.1.3-dark-welcome.png)

Features
--------

[](#features)

- 💎 Colorful, typed, easy-on-the eye dump variable highlight
- ✨ Dump n arguments
- 🐘 One-click PHP server run (no extras required)
- 👻 Filter messages by [Topics](#topic) and [Emotes](#emote)
- ✍️ Re-name "XR Session" to anything you want
- 🏁 Resume, Pause, Stop and Clear debug window controls
- 🥷 Keyboard shortcuts for ninjas (Resume **R**, Pause **P**, Stop **S** and Clear **C**)
- 😊 Export message to clipboard (plain text) or as inline-download PNG image
- 📟 Generates dump [backtrace](#flags)
- ⏸ [Pause](#flags) and resume your code execution (\*not implemented)
- 🌚 Dark / 🌝 Light mode follows your system preferences
- 👽 Ephemeral, it doesn't store any persistent data
- 🍒 HTML based (save page, search, shortcuts, etc.)
- 🔥 Uses [FiraCode](https://github.com/tonsky/FiraCode) font for displaying *beautiful looking dumps* ™
- 😅 Handle exceptions (hook or replace your existing handler)

 [![XR light demo](.screen/xr-0.1.3-light-demo.png)](.screen/xr-0.1.3-light-demo.png) [![XR dark demo](.screen/xr-0.1.3-dark-demo.png)](.screen/xr-0.1.3-dark-demo.png)

Contributing
------------

[](#contributing)

Feel free to contribute on [issues](https://github.com/chevere/xr/issues) and [discussions](https://github.com/chevere/xr/discussions) with your thoughts in how to improve XR.

Getting started
---------------

[](#getting-started)

- Add `chevere/xr` as a dev dependency in your project:

```
composer require --dev chevere/xr
```

`🚧 Min stability dev`

You will require to add this to your `composer.json` file.

```
    "minimum-stability": "dev",
    "prefer-stable": true
```

Start the server
----------------

[](#start-the-server)

```
php vendor/chevere/xr/server.php -p 27420
```

The server will be available at

Demo
----

[](#demo)

Open the debugger and then run:

```
php vendor/chevere/xr/demo.php
```

XR Helpers
----------

[](#xr-helpers)

### Dump variables

[](#dump-variables)

Use `xr($var1, $var2,...)` to dump *any variable* from your code.

```
xr($var, 'Hola, mundo!');
```

### Topic

[](#topic)

Add a topic passing `t:`.

```
xr(
    $var,
    'Hola, mundo!',
    t: 'Epic win'
);
```

### Emote

[](#emote)

Add an emote passing `e:`.

```
xr(
    $var,
    'Hola, mundo!',
    t: 'Epic win',
    e: '😎'
);
```

### Flags

[](#flags)

Pass bitwise flags to trigger special behavior.

- `f: XR_BACKTRACE` to dump debug backtrace.

```
xr(
    $var,
    'Hola, mundo!',
    t: 'Epic win',
    e: '😎',
    f: XR_BACKTRACE
);
```

- `f: XR_PAUSE` to pause code execution (\*not implemented).

```
xr(
    $var,
    'Hola, mundo!',
    t: 'Epic win',
    e: '😎',
    f: XR_PAUSE
);
```

### Send raw message

[](#send-raw-message)

Use `xrr` to send a raw message to the server.

💡 `xrr` also supports [topic](#topic) `t`, [emote](#emote) `e` and [flags](#flags) `f` arguments.

```
xrr(
    'Hola, mundo!',
    t: 'Greet'
);
```

### Exception handling

[](#exception-handling)

Use `registerThrowableHandler` to enable XR to handle throwables.

```
use Chevere\Xr\registerThrowableHandler;

// True append XR's to your existing handler
// False use only XR's handler
registerThrowableHandler(true);
```

Alternatively, you can use `throwableHandler` in any existing exception handler logic:

```
use Chevere\Xr\throwableHandler;

set_exception_handler(
    function(Throwable $throwable) {
        // ...
        try {
            throwableHandler($throwable);
        } catch(Throwable) {
            // Don't panic
        }
    }
);
```

### Error handling

[](#error-handling)

You will require to handle errors as exceptions and from there use [Exception handling](#exception-handling).

```
use use Chevere\ThrowableHandler\ThrowableHandler;

set_error_handler(
    ThrowableHandler::ERRORS_AS_EXCEPTIONS
);
register_shutdown_function(
    ThrowableHandler::FATAL_ERROR_HANDLER
);
```

Configuration
-------------

[](#configuration)

Optionally configure XR by creating a file named `xr.php` in your project directory with the following options:

- `enable`
    - `bool` Controls sending messages to the server. Set true to enable, false to disable.
- `host`
    - `string` The hostname/IP address where XR server is running.
- `port`
    - `int` Port to connect to the `host`.

The following example is a `xr.php` file with default settings.

```
