ips-laravel/huntglitch

Huntglitch package for the Laravel

Installs: 12

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ips-laravel/huntglitch

1.0.5 2025-09-29 13:30 UTC

This package is auto-updated.

Last update: 2025-09-29 13:34:38 UTC


README

Huntglitch is a development monitoring platform that can help you instantly solve bugs, broken codes and avoid crashes and false API calls with ease. Huntglitch gives you answers, not hints.

You can use Huntglitch to find out any errors or bugs in the critical codes of your app or software, quickly find out bugs, prevent lags due to rising user requests by forecasting future demand and quickly monitor the overall health of your app or software with ease.

#Logging  #Debugging  #Laravel  #PHP  #Monitoring  #QueryLogger

Documentation

Getting Started with Huntglitch

Before implementing the package, please complete these setup steps:

  1. Register an Account
    Sign up for a free Huntglitch account here: https://app.huntglitch.com/register

  2. Create a Project
    Once registered, create a new project here: https://app.huntglitch.com/project/create

  3. Follow the Installation & Implementation Guide
    Implement this package in your Laravel application by following the steps in the Installation and Usage in Laravel sections of this README.

  4. View Your Logs & Error Reports
    After the integration is complete and your application starts generating logs, you can view all errors, warnings, and queries in your Huntglitch dashboard:
    https://app.huntglitch.com/projects → Select your project to view detailed logs.

Features

  • Automatic logging of exceptions and errors
  • Track and store MySQL query logs
  • Integrate easily with Laravel exception handler
  • PSR-4 autoloading support
  • Laravel vendor publish support for easy config
  • Built-in support for tagging logs with severity levels

Supported Versions

  • PHP: ^8.0
  • Laravel: ^9.0 | ^10.0 | ^11.0 | ^12.0

Installation

Run the following command to install the package via Composer:

composer require ips-laravel/huntglitch

Environment Variables

Add these variables to your .env file:

HUNTGLITCH_PROJECT_ID={your-project-id}
HUNTGLITCH_DELIVERABLE_ID={your-deliverable-id}
HUNTGLITCH_LOG_ENDPOINT=https://api.huntglitch.com/
HUNTGLITCH_JS_DOMAIN=example.com,anotherdomain.com,sub.site.com

Then publish the Huntglitch config file:

php artisan vendor:publish --provider="Itpath\Huntglitch\HuntglitchServiceProvider" --tag=config

This will create config/huntglitch.php in your app. The package will automatically use these values from your .env file—no need to edit config/app.php.

Usage in Laravel

➤ Basic Usage in a try-catch block

use Itpath\Huntglitch\Huntglitch;

try {
    echo 100 / 0;
} catch (Throwable $e) {
    $glitch = new Huntglitch();
    $glitch->add($e);
}

➤ Global Usage for Exception Logging

For Laravel 9, 10, and 11 (Handler.php method)

Update the register() method in app/Exceptions/Handler.php:

use Itpath\Huntglitch\Huntglitch;

public function register()
{
    $this->reportable(function (Throwable $e) {
        $glitch = new Huntglitch();
        $glitch->add($e);
    });
}

For Laravel 12 (bootstrap/app.php method)

In Laravel 12, the Handler.php file is no longer used for exception handling.
Instead, open bootstrap/app.php and add the following inside the exception configuration section:

use Illuminate\Foundation\Configuration\Exceptions;
use Itpath\Huntglitch\Huntglitch;

->withExceptions(function (Exceptions $exceptions): void {
    $exceptions->report(function (\Throwable $e) {
        $glitch = new Huntglitch();
        $glitch->add($e);
    });
})
->create();

JavaScript Frontend Error Logging

You can send frontend (browser) errors directly to Huntglitch using the built-in JS log route. This allows you to collect logs from your website or web app without any backend code changes.

How it works

  • The package automatically registers a POST route at /huntglitch/js-log.
  • You can use the provided JS snippet or your own error collector to send logs to this endpoint.
  • The route will only accept requests from allowed domains (see below).

Setup

  1. Configure Allowed Domains

    In your .env file, add:

    HUNTGLITCH_JS_DOMAIN=example.com,anotherdomain.com,sub.site.com

    This will restrict log submissions to only those domains. Use a comma to separate multiple domains.

  2. Include the JS Collector

    Add the following script to your HTML:

    <script src="https://app.huntglitch.com/huntglitch.js"></script>
    <script>
        HuntGlitchAutoInit('ADD_YOUR_BACKEND_URL/huntglitch/js-log');
    </script>

    Replace ADD_YOUR_BACKEND_URL with your backaend laravel URL. No need to change for /huntglitch/js-log as it's default laravel route from HuntGlitch.

  3. Frontend JS Example

    The JS collector will automatically capture errors and send them to your Laravel backend:

    window.HuntGlitchAutoInit = function(url) {
        HuntGlitch.init({
            endpoint: url,
            captureConsole: true,
            batchSize: 1,
            // ...other options
        });
    };
    // See huntglitch.js for full options and customization

What gets sent

  • The JS collector sends error details, stack trace, file, line, and browser info.
  • The Laravel package automatically adds your Huntglitch project and deliverable IDs to each log.

Security

  • Only requests from allowed domains (as set in HUNTGLITCH_JS_DOMAIN) will be accepted.
  • Requests from other domains will be rejected with a 403 error.

Methods Overview

add($exception, $type = 'error', $additionalData = [])

  • Logs a message or exception
  • Optional second parameter sets severity (e.g., debug, info, warning, error)
  • Third optional parameter is an array for custom context data

Predefined Logging Methods

You can also use:

addError($e, $data);
addWarning($e, $data);
addInfo($e, $data);
addDebug($e, $data);
addNotice($e, $data);

All these methods accept:

  • string|Throwable $e
  • array $data (optional)

FAQs

1. What does this package do?

The Huntglitch package provides an Error & Query Logger Package to monitor errors, warning, info and debug of Laravel applications.

2. How do I install the package?

Run the following command in your terminal:

composer require ips-laravel/huntglitch

3. Which Laravel versions are supported?

This package supports Laravel 9, 10, 11, and 12 with PHP 8+ compatibility.

4. How do I update the package to the latest version?

Run the following command to update:

composer update ips-laravel/huntglitch

5. Can I contribute to this package?

Absolutely! Contributions are welcome. See the CONTRIBUTING guidelines for details.

6. Where can I get support?

For any support or queries, feel free to contact us.

Contributing

We welcome contributions from the community! Feel free to Fork the repository and contribute to this module. You can also create a pull request, and we will merge your changes into the main branch. See CONTRIBUTING for details.

Security Vulnerabilities

Please review our Security Policy on how to report security vulnerabilities.

License

This package is open-source and available under the MIT License. See the LICENSE file for details.

Get Support

  • Feel free to contact us if you have any questions.
  • If you find this project helpful, please give us a ⭐ Star.

You may also find our other useful packages: