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

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

mconsult/anfi-debug
===================

A Laravel package for caching and viewing debug variables in Octane apps.

0.1.7(2mo ago)0685PHPPHP &gt;=8.3

Since Oct 26Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/MillerlandyConsult/anfi-debug)[ Packagist](https://packagist.org/packages/mconsult/anfi-debug)[ RSS](/packages/mconsult-anfi-debug/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (2)Versions (18)Used By (0)

Custom Debugging Package for Laravel Octane
===========================================

[](#custom-debugging-package-for-laravel-octane)

This package provides a custom debugging solution for Laravel applications using Octane, where traditional debugging tools like Xdebug might not be available. It allows developers to cache variables and view them in a modern, user-friendly web interface that updates every 5 seconds.

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Cache Variables with `_debug()`](#cache-variables-with-_debug)
    - [Remove Cached Variables with `_forget()`](#remove-cached-variables-with-_forget)
    - [View Cached Variables](#view-cached-variables)
- [Full Example](#full-example)
- [Security Considerations](#security-considerations)
- [Customization](#customization)
- [Compatibility](#compatibility)
- [License](#license)
- [Contributing](#contributing)
- [Contact](#contact)

---

Introduction
------------

[](#introduction)

This package offers a custom debugging solution for Laravel applications running with Octane, allowing developers to cache variables and display them in a modern, user-friendly web interface that automatically updates every 5 seconds.

Features
--------

[](#features)

- **Cache Variables:** Allows you to cache any variables for debugging purposes.
- **User-Friendly Web Interface:** View cached variables in a modern and easy-to-use web interface.
- **Automatic Refresh:** The interface updates every 5 seconds to display the latest values.
- **Easy Installation:** Simple installation via Composer.
- **Laravel Compatibility:** Supports Laravel 8.x, 9.x, 10.x, and 11.x.

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

[](#installation)

**Step 1:** Require the package using Composer.

```
composer require mconsult/anfi-debug
```

**Note:** Ensure your `composer.json` includes the repository if necessary.

**Step 2:** Publish the package assets.

```
php artisan vendor:publish --provider="ANFI\DebugPackage\DebugServiceProvider" --tag="public" --tag="views"
```

This command will copy the CSS files to your `public` directory and the views to your `resources/views/vendor` directory.

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

[](#configuration)

No additional configuration is required. The package automatically registers its Service Provider through Laravel's package discovery.

Usage
-----

[](#usage)

### Cache Variables with `_debug()`

[](#cache-variables-with-_debug)

Use the global `_debug()` function to cache variables for debugging.

**Example:**

```
// Cache variables
$key = _debug([
    'variable1' => $value1,
    'variable2' => $value2,
    // Add as many variables as needed
]);
```

- **Parameters:**

    - `array $variables`: An associative array of variables to cache.
    - `string $key` (optional): A custom key for the cache entry.
- **Returns:**

    - `string`: The key used to store the variables in the cache.

**Using a Custom Key:**

```
$key = _debug($variables, 'my-custom-key');
```

### Remove Cached Variables with `_forget()`

[](#remove-cached-variables-with-_forget)

To remove cached variables, use the global `_forget()` function.

**Example:**

```
$success = _forget($key);

if ($success) {
    echo "Cache key '{$key}' has been removed.";
} else {
    echo "Cache key '{$key}' does not exist.";
}
```

- **Parameters:**

    - `string $key`: The key of the cached variables to remove.
- **Returns:**

    - `bool`: `true` if the key existed and was removed, `false` otherwise.

### View Cached Variables

[](#view-cached-variables)

Navigate to the following URL in your browser to view the cached variables:

```
http://your-app-url/debug/{key}

```

- Replace `{key}` with the key returned by the `_debug()` function.

**Example:**

```
http://localhost:8000/debug/debug-614c1b5e5f8b

```

The interface will display the cached variables and automatically refresh every 5 seconds to reflect any changes.

Full Example
------------

[](#full-example)

Here's a complete example of how to use the package:

```
