PHPackages                             workdoneright/laravel-api-guardian - 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. [API Development](/categories/api)
4. /
5. workdoneright/laravel-api-guardian

ActiveLibrary[API Development](/categories/api)

workdoneright/laravel-api-guardian
==================================

Advanced API error handling for Laravel with multiple format support, smart debugging, and developer-friendly features

00[5 PRs](https://github.com/abishekrsrikaanth/laravel-api-guardian/pulls)PHPCI passing

Since Feb 4Pushed 1mo agoCompare

[ Source](https://github.com/abishekrsrikaanth/laravel-api-guardian)[ Packagist](https://packagist.org/packages/workdoneright/laravel-api-guardian)[ RSS](/packages/workdoneright-laravel-api-guardian/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (7)Used By (0)

Laravel API Guardian
====================

[](#laravel-api-guardian)

[![Latest Version on Packagist](https://camo.githubusercontent.com/47ed2cfd592fc3765667cdbe015aca2ed7e9592044735bf093899db637c12415/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f776f726b646f6e6572696768742f6c61726176656c2d6170692d677561726469616e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/workdoneright/laravel-api-guardian)[![Total Downloads](https://camo.githubusercontent.com/63b166931c089318c75f382874cd74422cbdb8065e15d8ddccc8feb95d653b7f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776f726b646f6e6572696768742f6c61726176656c2d6170692d677561726469616e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/workdoneright/laravel-api-guardian)

Advanced API error handling for Laravel with multiple format support, smart debugging, and developer-friendly features.

Features
--------

[](#features)

- 🎯 **Multiple Error Formats**: JSend, RFC 7807, JSON:API, GraphQL out of the box
- 🔧 **Developer-Friendly**: Smart error context, suggestions, and documentation links
- 🐛 **Enhanced Debugging**: Stack traces, query logs, clickable file paths for development
- 🔒 **Production-Safe**: Automatic sensitive data masking and PII redaction
- 🌍 **Multi-Language Support**: Localized error messages
- 📊 **Real-time Monitoring Dashboard**: Live error tracking, analytics, and trend analysis
- 🔄 **Smart Error Recovery**: Automatic retry logic with exponential backoff
- ⚡ **Circuit Breaker Pattern**: Prevents cascading failures with automatic recovery
- 📈 **Error Analytics**: Trend analysis, performance impact metrics, and insights
- 🛡️ **Graceful Degradation**: Custom fallback strategies and contextual recovery suggestions
- 🎨 **Fluent API**: Clean, expressive exception creation
- 📝 **Auto-Documentation**: Generate error documentation in multiple formats
- ✅ **Validation Enhancement**: Better validation error responses with suggestions
- 🧪 **Testing Utilities**: Helpers for testing error scenarios

Feature Quick Reference
-----------------------

[](#feature-quick-reference)

FeatureQuick StartDocumentation**Error Monitoring Dashboard**`GET /api-guardian/dashboard`[Full Guide →](docs/MONITORING.md)**Smart Error Recovery**`ApiGuardian::recovery()->execute()`[Full Guide →](docs/RECOVERY.md)**Circuit Breaker**`CircuitBreaker::getOrCreate('service')`[Full Guide →](docs/RECOVERY.md)**Error Analytics**`$collector->getAnalytics(7)`[Full Guide →](docs/MONITORING.md)**Custom Fallbacks**`$recovery->registerFallbackStrategy()`[Full Guide →](docs/RECOVERY.md)Installation
------------

[](#installation)

You can install the package via composer:

```
composer require workdoneright/laravel-api-guardian
```

Publish the configuration and migration files:

```
php artisan vendor:publish --tag="api-guardian-config"
php artisan vendor:publish --tag="api-guardian-migrations"
```

Run the migration:

```
php artisan migrate
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use WorkDoneRight\ApiGuardian\Facades\ApiGuardian;

// Throw a not found error
ApiGuardian::notFound('User not found')->throw();

// Create a custom error with fluent interface
ApiGuardian::exception('Invalid payment method')
    ->code('INVALID_PAYMENT_METHOD')
    ->statusCode(400)
    ->meta(['accepted_methods' => ['visa', 'mastercard']])
    ->suggestion('Please use a valid payment method')
    ->link('https://docs.example.com/payments')
    ->throw();
```

### Using the ApiException Class

[](#using-the-apiexception-class)

```
use WorkDoneRight\ApiGuardian\Exceptions\ApiException;

// Simple usage
throw ApiException::notFound('Resource not found');

// With fluent interface
ApiException::make('Custom error')
    ->code('CUSTOM_ERROR')
    ->statusCode(400)
    ->meta(['key' => 'value'])
    ->suggestion('Try this instead')
    ->recoverable()
    ->throw();
```

### Recovery-Enhanced Exceptions

[](#recovery-enhanced-exceptions)

```
// Create recoverable exceptions with automatic retry support
ApiException::make('Temporary service issue')
    ->code('SERVICE_UNAVAILABLE')
    ->statusCode(503)
    ->recoverable(true)
    ->throw();

// Get recovery suggestions for any exception
$exception = new \Exception('Connection timeout');
$suggestions = ApiException::fromThrowable($exception)->getRecoverySuggestions();
```

### Quick Exception Helpers

[](#quick-exception-helpers)

```
// Pre-configured exceptions
ApiGuardian::notFound('User not found')->throw();
ApiGuardian::unauthorized('Invalid credentials')->throw();
ApiGuardian::forbidden('Access denied')->throw();
ApiGuardian::validationFailed('Invalid input')->throw();
ApiGuardian::badRequest('Invalid request')->throw();
ApiGuardian::rateLimitExceeded('Too many requests', 60)->throw();
ApiGuardian::serverError('Something went wrong')->throw();
```

### Using Smart Error Recovery

[](#using-smart-error-recovery)

```
// Basic recovery with automatic retries
try {
    $result = ApiGuardian::recovery()->execute('external-api', function () {
        return Http::timeout(10)->get('https://api.example.com/data')->json();
    });

    return $result;
} catch (Exception $e) {
    // Recovery failed, handle the error
    return response()->json(['error' => 'Service unavailable'], 503);
}

// With custom fallback strategy
ApiGuardian::recovery()->registerFallbackStrategy('payment-service', function ($e) {
    return ['error' => 'Payment temporarily unavailable', 'retry_after' => 30];
});
```

### Monitoring Errors

[](#monitoring-errors)

After setting up the monitoring dashboard:

```
// Access error analytics programmatically
use WorkDoneRight\ApiGuardian\Services\ErrorCollector;

$collector = app(ErrorCollector::class);
$analytics = $collector->getAnalytics(7); // Last 7 days
$liveErrors = $collector->getLiveErrors(10); // Last 10 errors

// Example: Get recent critical errors
$criticalErrors = \WorkDoneRight\ApiGuardian\Models\ApiError::where('status_code', '>=', 500)
    ->recent(24) // Last 24 hours
    ->unresolved()
    ->orderBy('created_at', 'desc')
    ->get();
```

Error Formats
-------------

[](#error-formats)

### JSend Format (Default)

[](#jsend-format-default)

```
{
  "status": "fail",
  "message": "User not found",
  "code": "RESOURCE_NOT_FOUND",
  "data": {
    "error_id": "err_abc123xyz",
    "timestamp": "2026-01-31T12:00:00Z",
    "suggestion": "Check if the user ID is correct"
  }
}
```

### RFC 7807 (Problem Details)

[](#rfc-7807-problem-details)

```
{
  "type": "https://api.example.com/errors/resource-not-found",
  "title": "Not Found",
  "status": 404,
  "detail": "User not found",
  "instance": "err_abc123xyz",
  "suggestion": "Check if the user ID is correct"
}
```

### JSON:API

[](#jsonapi)

```
{
  "errors": [
    {
      "id": "err_abc123xyz",
      "status": "404",
      "code": "RESOURCE_NOT_FOUND",
      "title": "Not Found",
      "detail": "User not found",
      "meta": {
        "timestamp": "2026-01-31T12:00:00Z",
        "suggestion": "Check if the user ID is correct"
      }
    }
  ]
}
```

### GraphQL

[](#graphql)

```
{
  "errors": [
    {
      "message": "User not found",
      "locations": [{"line": 5, "column": 10}],
      "path": ["user", "email"],
      "extensions": {
        "code": "RESOURCE_NOT_FOUND",
        "category": "not_found",
        "errorId": "err_abc123xyz",
        "timestamp": "2026-01-31T12:00:00Z",
        "suggestion": "Check if the user ID is correct"
      }
    }
  ],
  "data": null
}
```

[Read the full GraphQL documentation →](internal-docs/GRAPHQL.md)

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

[](#configuration)

The configuration file provides extensive customization options:

```
// config/api-guardian.php

return [
    // Default error format: jsend, rfc7807, jsonapi, graphql, custom
    'default_format' => env('API_GUARDIAN_FORMAT', 'jsend'),

    // Enable/disable various context information
    'context' => [
        'include_error_id' => true,
        'include_timestamp' => true,
        'include_suggestions' => true,
        'include_trace' => env('APP_DEBUG', false),
    ],

    // Development mode settings
    'development' => [
        'enabled' => env('APP_DEBUG', false),
        'include_file_path' => true,
        'clickable_paths' => true,
        'ide' => env('API_GUARDIAN_IDE', 'vscode'),
    ],

    // Security settings
    'security' => [
        'mask_sensitive_data' => true,
        'pii_redaction' => [
            'enabled' => true,
        ],
    ],

    // And much more...
];
```

Format Negotiation
------------------

[](#format-negotiation)

You can use middleware to automatically detect the format from the Accept header:

```
// In your routes
Route::middleware('api-guardian')->group(function () {
    Route::get('/users', [UserController::class, 'index']);
});

// Or specify a format
Route::middleware('api-guardian:rfc7807')->group(function () {
    Route::get('/users', [UserController::class, 'index']);
});
```

### Accept Header Detection

[](#accept-header-detection)

```
# Request with RFC 7807
curl -H "Accept: application/problem+json" https://api.example.com/users

# Request with JSON:API
curl -H "Accept: application/vnd.api+json" https://api.example.com/users
```

Validation Errors
-----------------

[](#validation-errors)

Enhanced validation error responses with error codes and suggestions:

```
{
  "status": "fail",
  "message": "Validation failed",
  "data": {
    "email": {
      "message": "The email must be a valid email address",
      "code": "INVALID_EMAIL"
    },
    "password": {
      "message": "The password field is required",
      "code": "FIELD_REQUIRED"
    }
  }
}
```

Artisan Commands
----------------

[](#artisan-commands)

### List All Errors

[](#list-all-errors)

```
php artisan errors:list
```

### Generate Documentation

[](#generate-documentation)

```
# Generate markdown documentation
php artisan errors:generate-docs --format=markdown

# Generate HTML documentation
php artisan errors:generate-docs --format=html

# Generate OpenAPI schema
php artisan errors:generate-docs --format=openapi
```

### Test Error Rendering

[](#test-error-rendering)

```
php artisan errors:test NOT_FOUND --format=jsend --message="Custom message"
```

### Analyze Error Patterns

[](#analyze-error-patterns)

```
php artisan errors:analyze --days=7
```

Development vs Production
-------------------------

[](#development-vs-production)

### Development Mode

[](#development-mode)

When `APP_DEBUG=true`, API Guardian includes:

- Full stack traces
- Clickable file paths (IDE integration)
- Query logs for database errors
- Request/response dumps
- Exception chain visualization

### Production Mode

[](#production-mode)

When `APP_DEBUG=false`, API Guardian:

- Hides sensitive information
- Masks passwords, tokens, API keys
- Redacts PII (emails, phone numbers)
- Shows user-friendly error messages
- Includes error IDs for support reference

Testing
-------

[](#testing)

API Guardian includes helpful testing utilities:

```
use WorkDoneRight\ApiGuardian\Exceptions\ApiException;

it('handles not found errors', function () {
    $this->getJson('/api/users/999')
        ->assertStatus(404)
        ->assertJsonStructure([
            'status',
            'message',
            'code',
            'data',
        ]);
});
```

Run tests:

```
composer test
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom Exception Handler

[](#custom-exception-handler)

If you need full control, you can extend the exception handler:

```
namespace App\Exceptions;

use WorkDoneRight\ApiGuardian\Exceptions\Handler as ApiGuardianHandler;

class Handler extends ApiGuardianHandler
{
    protected function shouldHandleApiException($request): bool
    {
        // Custom logic to determine if this should be handled as API error
        return parent::shouldHandleApiException($request);
    }
}
```

### Custom Formatter

[](#custom-formatter)

Create your own error formatter:

```
use WorkDoneRight\ApiGuardian\Contracts\ErrorFormatterContract;

class CustomFormatter implements ErrorFormatterContract
{
    public function format(Throwable $exception, ?int $statusCode = null): JsonResponse
    {
        // Your custom formatting logic
    }

    // Implement other required methods...
}

// Use it
ApiGuardian::useFormatter(new CustomFormatter());
```

Real-time Error Monitoring Dashboard
------------------------------------

[](#real-time-error-monitoring-dashboard)

The package includes a comprehensive real-time monitoring dashboard for tracking API errors, analytics, and trends.

### Dashboard Setup

[](#dashboard-setup)

After running migrations, you can access the dashboard at `/api-guardian/dashboard` (requires authentication).

### Environment Configuration

[](#environment-configuration)

Add these settings to your `.env` file:

```
API_GUARDIAN_MONITORING_ENABLED=true
API_GUARDIAN_RETENTION_DAYS=30
API_GUARDIAN_DB_CONNECTION=null  # Use default connection
```

### Dashboard API Endpoints

[](#dashboard-api-endpoints)

```
# Main dashboard data (analytics + live errors + circuit breakers)
GET /api-guardian/dashboard

# Analytics data with custom time range
GET /api-guardian/analytics?days=7

# Live error feed with limit
GET /api-guardian/errors/live?limit=50

# Advanced error search and filtering
GET /api-guardian/errors/search?search=keyword&status_code=404&resolved=false

# Get specific error details
GET /api-guardian/errors/{id}

# Mark error as resolved
POST /api-guardian/errors/{id}/resolve

# Circuit breaker status
GET /api-guardian/circuit-breakers

# Reset circuit breaker
POST /api-guardian/circuit-breakers/reset

# Export errors (CSV or JSON)
GET /api-guardian/export?format=csv&days=7
```

### Search and Filter Examples

[](#search-and-filter-examples)

```
// Search errors by keyword
fetch('/api-guardian/errors/search?search=database')

// Filter by status code
fetch('/api-guardian/errors/search?status_code=404')

// Filter resolved/unresolved errors
fetch('/api-guardian/errors/search?resolved=false')

// Combine filters
fetch('/api-guardian/errors/search?search=timeout&status_code=500&resolved=true')
```

### Frontend Integration

[](#frontend-integration)

```
// Live error updates
const pollErrors = async () => {
    const response = await fetch('/api-guardian/errors/live');
    const errors = await response.json();
    updateErrorFeed(errors);
};

// Analytics dashboard
const loadAnalytics = async (days = 7) => {
    const response = await fetch(`/api-guardian/analytics?days=${days}`);
    const data = await response.json();
    renderCharts(data);
};

// Error resolution
const resolveError = async (errorId) => {
    await fetch(`/api-guardian/errors/${errorId}/resolve`, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' }
    });
    refreshErrorList();
};
```

### Error Analytics

[](#error-analytics)

The dashboard provides comprehensive analytics:

- **Total Errors**: Overall error count in time range
- **Unique Errors**: Distinct error instances
- **Unresolved Errors**: Active error issues
- **Top Errors**: Most frequent error patterns
- **Status Distribution**: Errors by HTTP status codes
- **Trend Data**: Hourly distribution over time

### Security Features

[](#security-features)

- **Sensitive Data Redaction**: Passwords, tokens, API keys automatically masked
- **PII Protection**: Email addresses, phone numbers, IP addresses redacted
- **Access Control**: Dashboard routes protected by authentication middleware
- **Data Retention**: Configurable automatic cleanup of old error data

Smart Error Recovery System
---------------------------

[](#smart-error-recovery-system)

Automatically handle transient failures with intelligent retry logic and circuit breaker patterns.

### Basic Recovery Usage

[](#basic-recovery-usage)

```
use WorkDoneRight\ApiGuardian\Facades\ApiGuardian;

try {
    $result = ApiGuardian::recovery()->execute('external-service', function () {
        // Your operation here
        return Http::timeout(10)->get('https://api.example.com/data');
    });

    return $result;
} catch (Exception $e) {
    // Handle final failure after all retries
    Log::error('Operation failed after recovery attempts', [
        'error' => $e->getMessage()
    ]);
}
```

### Service Wrapper Pattern

[](#service-wrapper-pattern)

```
namespace App\Services;

use WorkDoneRight\ApiGuardian\Services\SmartErrorRecovery;

class ApiService
{
    protected SmartErrorRecovery $recovery;

    public function __construct(SmartErrorRecovery $recovery)
    {
        $this->recovery = $recovery;
    }

    public function fetchUserData(int $userId): array
    {
        return $this->recovery->execute('user-service', function () use ($userId) {
            return Http::timeout(5)->get("https://users.example.com/api/users/{$userId}")->json();
        }, "fetch-user-{$userId}");
    }
}
```

### Custom Fallback Strategies

[](#custom-fallback-strategies)

```
use WorkDoneRight\ApiGuardian\Services\SmartErrorRecovery;

$recovery = app(SmartErrorRecovery::class);

// Register custom fallback for specific service
$recovery->registerFallbackStrategy('payment-gateway', function (Exception $e) {
    if ($e->getMessage() === 'Service temporarily unavailable') {
        return [
            'error' => 'Payment service temporarily unavailable',
            'message' => 'Please try again in a few moments',
            'retry_after' => 30,
            'type' => 'payment_error',
        ];
    }

    return [
        'error' => 'Payment processing failed',
        'message' => 'Please contact support or try alternative payment method',
        'type' => 'payment_error',
    ];
});
```

### Circuit Breaker Usage

[](#circuit-breaker-usage)

```
use WorkDoneRight\ApiGuardian\Models\CircuitBreaker;

// Get or create circuit breaker
$breaker = CircuitBreaker::getOrCreate('payment-gateway', 'process-payment');

// Manual circuit breaker operations
if ($breaker->canAttempt()) {
    try {
        $result = $paymentGateway->process($payment);
        $breaker->recordSuccess();
        return $result;
    } catch (Exception $e) {
        $breaker->recordFailure();

        if ($breaker->isOpen()) {
            return response()->json([
                'error' => 'Service temporarily unavailable',
                'retry_after' => $breaker->next_attempt_at->diffInSeconds(now())
            ], 503);
        }

        throw $e;
    }
} else {
    // Circuit is open, use fallback
    return $this->fallbackResponse();
}

// Check circuit breaker state
if ($breaker->isOpen()) {
    $retryAfter = $breaker->next_attempt_at->diffInSeconds(now());
    return response()->json([
        'error' => 'Service temporarily unavailable',
        'retry_after' => $retryAfter
    ], 503);
}
```

### Recovery Configuration

[](#recovery-configuration)

Add recovery settings to your `.env` file:

```
API_GUARDIAN_RECOVERY_ENABLED=true
API_GUARDIAN_MAX_RETRIES=3
API_GUARDIAN_BASE_DELAY=1000
```

### Recovery Configuration Options

[](#recovery-configuration-options)

```
// config/api-guardian.php
'recovery' => [
    'enabled' => true,
    'max_retries' => 3,
    'base_delay' => 1000, // milliseconds
    'backoff_multiplier' => 2.0,
    'transient_error_patterns' => [
        '/timeout/i',
        '/connection/i',
        '/network/i',
        '/temporary/i',
        '/503/',
        '/502/',
        '/504/',
        '/429/',
    ],
    'transient_status_codes' => [429, 502, 503, 504],
    'auto_recovery' => [
        'enabled' => true,
        'safe_methods' => ['GET', 'HEAD'],
    ],
],

'circuit_breaker' => [
    'failure_threshold' => 5,
    'recovery_timeout' => 60, // seconds
    'success_threshold' => 3,
    'half_open_max_calls' => 3,
    'auto_reset' => true,
    'reset_after' => 3600, // seconds
],
```

### Recovery Suggestions

[](#recovery-suggestions)

The system automatically generates contextual recovery suggestions:

```
use WorkDoneRight\ApiGuardian\Services\SmartErrorRecovery;

$recovery = app(SmartErrorRecovery::class);

// Get recovery suggestions for any exception
$suggestions = $recovery->generateRecoverySuggestion($exception);

// Example output for timeout error:
[
    'type' => 'timeout',
    'message' => 'The operation timed out. Consider increasing the timeout or optimizing the request.',
    'actions' => [
        'Try again with a longer timeout',
        'Check if the request payload can be optimized',
        'Verify network connectivity'
    ]
]
```

### Health Check Integration

[](#health-check-integration)

```
// Add to routes/web.php or routes/api.php
Route::get('/health/api-guardian', function () {
    $breakers = \WorkDoneRight\ApiGuardian\Models\CircuitBreaker::all();
    $healthy = $breakers->where('state', 'closed')->count();
    $total = $breakers->count();

    return response()->json([
        'status' => $healthy === $total ? 'healthy' : 'degraded',
        'healthy_breakers' => $healthy,
        'total_breakers' => $total,
        'details' => $breakers->map(function ($breaker) {
            return [
                'service' => $breaker->service,
                'state' => $breaker->state,
                'can_attempt' => $breaker->canAttempt(),
            ];
        })
    ], $healthy === $total ? 200 : 503);
});
```

### Monitoring Recovery Performance

[](#monitoring-recovery-performance)

```
// In AppServiceProvider or similar
Event::listen('api-guardian.recovery.attempted', function ($service, $attempt, $maxAttempts) {
    Log::info("Recovery attempt", [
        'service' => $service,
        'attempt' => $attempt,
        'max_attempts' => $maxAttempts
    ]);
});

Event::listen('api-guardian.recovery.succeeded', function ($service, $attempts) {
    Log::info("Recovery succeeded", [
        'service' => $service,
        'attempts_used' => $attempts
    ]);
});
```

Frontend Stack Support
----------------------

[](#frontend-stack-support)

The API Guardian package supports multiple frontend ecosystems, allowing you to choose the best stack for your application:

### 🎯 **Livewire 4 + Flux (Recommended)**

[](#-livewire-4--flux-recommended)

Real-time server-rendered components with reactive UI and minimal JavaScript.

#### Installation

[](#installation-1)

```
# Install additional dependencies
npm install @livewire/livewire
composer require livewire/livewire
```

#### Usage Example

[](#usage-example)

```
// routes/web.php
Route::middleware(['web', 'auth'])->group(function () {
    Route::get('/api-guardian/dashboard', function () {
        return view('api-guardian::dashboard');
    });
});
```

```
{{-- resources/views/api-guardian/dashboard.blade.php --}}

```

#### Key Features

[](#key-features)

- ✅ Real-time error feed with automatic updates
- ✅ Interactive charts and analytics
- ✅ Circuit breaker status monitoring
- ✅ Modal-based error details
- ✅ Search and filtering capabilities

---

### ⚡ **Inertia.js + Vue 3**

[](#-inertiajs--vue-3)

Single Page Application experience with client-side navigation and component-based architecture.

#### Installation

[](#installation-2)

```
npm install @inertiajs/vue3 vue@latest
npm install vue-chartjs chart.js
```

#### Usage Example

[](#usage-example-1)

```
// routes/web.php
Route::middleware(['web', 'auth'])->group(function () {
    Route::get('/api-guardian/dashboard', [InertiaDashboardController::class, 'index'])->name('api-guardian.dashboard');
});
```

```
{{-- resources/js/pages/ApiGuardian/Dashboard.vue --}}

import { Head } from '@inertiajs/vue3'
import Dashboard from '../../components/Dashboard.vue'

    API Guardian Dashboard

```

#### Key Features

[](#key-features-1)

- ✅ SPA navigation with browser history
- ✅ Client-side state management with composables
- ✅ Real-time updates with EventSource/WebSockets
- ✅ Advanced data visualization
- ✅ Smooth transitions and animations

---

### 🎨 **Vue 3 (SPA)**

[](#-vue-3-spa)

Traditional Single Page Application with Vue Router and Pinia for complete frontend control.

#### Installation

[](#installation-3)

```
npm install vue@latest vue-router@4 pinia
npm install vue-chartjs chart.js axios
```

#### Setup Example

[](#setup-example)

```
// resources/js/app.js
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import { createPinia } from 'pinia'
import App from './App.vue'

const app = createApp(App)

const router = createRouter({
  history: createWebHistory(),
  routes: [
    { path: '/api-guardian/dashboard', component: () => import('./views/Dashboard.vue') },
    { path: '/api-guardian/analytics', component: () => import('./views/Analytics.vue') },
  ]
})

const pinia = createPinia()

app.use(router)
app.use(pinia)
app.mount('#app')
```

#### Key Features

[](#key-features-2)

- ✅ Complete frontend control
- ✅ Advanced state management with Pinia
- ✅ Client-side routing and navigation
- ✅ Custom animations and transitions
- ✅ Integration with any backend framework

---

📊 **API Endpoints**
-------------------

[](#-api-endpoints)

All frontend stacks share the same REST API endpoints:

```
# Dashboard data
GET /api-guardian/dashboard

# Analytics with filtering
GET /api-guardian/analytics?days=7

# Error listing with search/filters
GET /api-guardian/errors/search?search=keyword&status_code=404&resolved=false

# Error details
GET /api-guardian/errors/{id}

# Resolve error
POST /api-guardian/errors/{id}/resolve

# Circuit breaker status
GET /api-guardian/circuit-breakers
POST /api-guardian/circuit-breakers/reset

# Export data
GET /api-guardian/export?format=csv&days=7
```

🔧 **Frontend Integration Examples**
-----------------------------------

[](#-frontend-integration-examples)

### Real-time Updates

[](#real-time-updates)

```
// Livewire (Flux components)

// Inertia.js + Vue (EventSource)
const { startRealTimeUpdates } = useApiGuardian()

onMounted(() => {
  startRealTimeUpdates()
})

// Vue SPA (WebSockets)
import io from 'socket.io-client'

const socket = io('http://localhost:6001')
socket.on('new-error', (error) => {
  store.commit('addError', error)
})
```

### Error Management

[](#error-management)

```
// Livewire (Flux)

// Inertia.js + Vue

```

### Analytics Dashboard

[](#analytics-dashboard)

```
// Livewire (Flux)

// Inertia.js + Vue

// Vue SPA (Chart.js)

import { ref, onMounted } from 'vue'
import { Chart } from 'chart.js'

const errorChart = ref(null)

onMounted(() => {
  new Chart(errorChart.value, {
    type: 'line',
    data: chartData,
    options: {
      responsive: true,
      scales: {
        y: { beginAtZero: true }
      }
    }
  })
})

```

Security
--------

[](#security)

- Automatic sensitive data masking (passwords, tokens, API keys)
- PII redaction (emails, phone numbers, IP addresses)
- SQL injection attempt logging
- Configurable data retention policies
- GDPR-compliant error logging

Documentation
-------------

[](#documentation)

- 📖 [Installation Guide](docs/INSTALL.md) - Detailed setup instructions
- 📚 [Usage Guide](docs/USAGE.md) - Complete usage examples
- 🔄 [Smart Error Recovery](docs/RECOVERY.md) - Retry logic and circuit breakers
- 📊 [Monitoring Dashboard](docs/MONITORING.md) - Real-time error tracking
- 🔧 [Extending Guide](docs/EXTENDING.md) - Custom formatters and strategies
- 🗺️ **[Roadmap](docs/ROADMAP.md) - Future features and version plans**
- ✨ [Recent Enhancements](internal-docs/ENHANCEMENTS.md) - Latest improvements

Changelog
---------

[](#changelog)

Please see [CHANGELOG](docs/CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](docs/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Abishek R Srikaanth](https://github.com/abishekrsrikaanth)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](docs/LICENSE.md) for more information.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance59

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/679089de897a6d3f79d14628be0e3a38b3d77ccfa7c1f85ca7de06ae7564b166?d=identicon)[abishekrsrikaanth](/maintainers/abishekrsrikaanth)

---

Top Contributors

[![abishekrsrikaanth](https://avatars.githubusercontent.com/u/1639302?v=4)](https://github.com/abishekrsrikaanth "abishekrsrikaanth (12 commits)")

### Embed Badge

![Health badge](/badges/workdoneright-laravel-api-guardian/health.svg)

```
[![Health](https://phpackages.com/badges/workdoneright-laravel-api-guardian/health.svg)](https://phpackages.com/packages/workdoneright-laravel-api-guardian)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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