Laravel / PHP SDK

Error tracking for Laravel applications - as simple as possible!

PHP 8.0+ Laravel 9.x - 12.x

Installation

composer require hymns/alertiqo-client-php

Configuration

Add to your .env file:

ALERTIQO_ENABLED=true
ALERTIQO_API_KEY=your-api-key
ALERTIQO_ENDPOINT=https://alertiqo.io

That's it! Exception handling is auto-registered via ServiceProvider. All exceptions will be automatically tracked.

Publish the config file (optional):

php artisan vendor:publish --tag=alertiqo-client-config

Test Your Setup

php artisan alertiqo:test

Usage

Automatic Error Tracking

All exceptions are automatically tracked. No additional setup needed!

Manual Error Capture

Using the Facade:

use Alertiqo\Laravel\Facades\Alertiqo;

// Capture exception
try {
    throw new \Exception('Something went wrong');
} catch (\Exception $e) {
    Alertiqo::captureException($e);
}

// Capture message
Alertiqo::captureMessage('User logged in', 'info');

// Add breadcrumb
Alertiqo::addBreadcrumb([
    'message' => 'User clicked button',
    'category' => 'user-action',
    'level' => 'info',
    'data' => ['button_id' => 'submit']
]);

// Set user context
Alertiqo::setUser([
    'id' => auth()->id(),
    'email' => auth()->user()->email,
    'name' => auth()->user()->name,
]);

// Set tags
Alertiqo::setTag('feature', 'checkout');
Alertiqo::setTags([
    'version' => '2.0.0',
    'subscription' => 'premium'
]);

Using Helper Functions

// Capture exception
alertiqo_capture($exception);

// Capture message
alertiqo_message('Payment processed', 'info');

// Add breadcrumb
alertiqo_breadcrumb('User navigated to checkout', 'navigation', 'info');

// Get instance
$client = alertiqo();
$client->setUser(['id' => 123]);

Advanced Features

Queue Configuration (Recommended)

By default, Alertiqo uses queues to send error reports asynchronously:

# Make sure queue worker is running
php artisan queue:work

Disable queue (not recommended):

ALERTIQO_USE_QUEUE=false

SQL Query Logging

Capture database queries as breadcrumbs:

ALERTIQO_LOG_SQL=true
ALERTIQO_SQL_THRESHOLD=100  # Only log queries > 100ms

Performance Monitoring

Track slow requests automatically:

ALERTIQO_PERFORMANCE_MONITORING=true
ALERTIQO_PERFORMANCE_THRESHOLD=1000  # Report requests > 1 second

Error Sampling

Control error capture rate for high-traffic apps:

ALERTIQO_SAMPLE_RATE=0.1  # Capture 10% of errors

Integration Examples

In Controllers

namespace App\Http\Controllers;

use Alertiqo\Laravel\Facades\Alertiqo;

class OrderController extends Controller
{
    public function store(Request $request)
    {
        Alertiqo::addBreadcrumb([
            'message' => 'Order creation started',
            'category' => 'order',
            'level' => 'info'
        ]);

        try {
            $order = Order::create($request->all());
            
            Alertiqo::captureMessage('Order created successfully', 'info', [
                'tags' => ['order_id' => $order->id]
            ]);
            
            return response()->json($order);
        } catch (\Exception $e) {
            Alertiqo::captureException($e, [
                'tags' => ['user_id' => auth()->id()]
            ]);
            
            return response()->json(['error' => 'Failed'], 500);
        }
    }
}

In Jobs

namespace App\Jobs;

use Alertiqo\Laravel\Facades\Alertiqo;

class ProcessPayment implements ShouldQueue
{
    public function handle()
    {
        Alertiqo::addBreadcrumb([
            'message' => 'Payment processing started',
            'category' => 'job',
            'level' => 'info'
        ]);

        try {
            // Process payment logic
        } catch (\Exception $e) {
            Alertiqo::captureException($e);
            throw $e;
        }
    }
}

In Middleware

namespace App\Http\Middleware;

use Closure;
use Alertiqo\Laravel\Facades\Alertiqo;

class TrackApiCalls
{
    public function handle($request, Closure $next)
    {
        Alertiqo::addBreadcrumb([
            'message' => 'API call: ' . $request->path(),
            'category' => 'api',
            'level' => 'info',
            'data' => [
                'method' => $request->method(),
                'path' => $request->path()
            ]
        ]);

        return $next($request);
    }
}

All Configuration Options

# Enable/disable tracking
ALERTIQO_ENABLED=true

# API credentials
ALERTIQO_API_KEY=your-api-key
ALERTIQO_ENDPOINT=https://alertiqo.io

# Release version
ALERTIQO_RELEASE=v1.0.6

# Debug mode
ALERTIQO_DEBUG=false

# Queue settings
ALERTIQO_USE_QUEUE=true
ALERTIQO_QUEUE=default

# SQL query logging
ALERTIQO_LOG_SQL=false
ALERTIQO_SQL_THRESHOLD=0

# Performance monitoring
ALERTIQO_PERFORMANCE_MONITORING=false
ALERTIQO_PERFORMANCE_THRESHOLD=1000

# Error sampling
ALERTIQO_SAMPLE_RATE=1.0

Vanilla PHP (Non-Laravel)

You can also use this package without Laravel. Follow the Installation and Configuration steps above, then instantiate the client directly:

<?php
require 'vendor/autoload.php';

use Alertiqo\Laravel\Alertiqo;

$alertiqo = new Alertiqo([
    'api_key' => 'your-api-key',
    'endpoint' => 'https://alertiqo.io',
    'environment' => 'production',
    'release' => 'v1.0.0',
    'use_queue' => false, // Must be false for non-Laravel
]);

// Set global exception handler
set_exception_handler(function ($e) use ($alertiqo) {
    $alertiqo->captureException($e);
});

// Manual capture
try {
    throw new Exception('Something went wrong');
} catch (Exception $e) {
    $alertiqo->captureException($e);
}

Note: Queue-based reporting requires Laravel. For vanilla PHP, set use_queue to false.