PHP code example of bluecapapps / downctl-laravel

1. Go to this page and download the library: Download bluecapapps/downctl-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bluecapapps / downctl-laravel example snippets


use Bluecapapps\DownctlLaravel\Facades\Downctl;

Downctl::captureException($e);

Downctl::report('Stripe webhook signature invalid', level: 'error');

Downctl::captureException($e, level: 'warning', context: [
    'user_id' => auth()->id(),
    'plan' => $user->plan,
]);

use Bluecapapps\DownctlLaravel\DownctlClient;

class PaymentService
{
    public function __construct(private DownctlClient $downctl) {}

    public function charge(Order $order): void
    {
        try {
            $this->gateway->charge($order);
        } catch (\Throwable $e) {
            $this->downctl->captureException($e, context: ['order_id' => $order->id]);
            throw $e;
        }
    }
}

'monitors' => [
    'reports_daily' => env('DOWNCTL_REPORTS_DAILY_MONITOR_TOKEN'),
    'cache_prune' => env('DOWNCTL_CACHE_PRUNE_MONITOR_TOKEN'),
],

use Illuminate\Support\Facades\Schedule;

Schedule::command('reports:daily')
    ->dailyAt('06:00')
    ->cronMonitor(config('downctl.monitors.reports_daily'));

Schedule::command('cache:prune')
    ->hourly()
    ->cronMonitor(config('downctl.monitors.cache_prune'));

use Bluecapapps\DownctlLaravel\Facades\Downctl;

// Simple heartbeat — marks the monitor as healthy
Downctl::pingCron('your-token');

// Lifecycle pings with optional metadata
Downctl::pingCronStarted('your-token');

Downctl::pingCronFinished('your-token', [
    'runtime'     => 12.4,  // seconds
    'memory'      => 52428800,  // bytes
]);

Downctl::pingCronFailed('your-token', [
    'exit_code'       => 1,
    'failure_message' => 'Connection to database timed out',
]);

// bootstrap/providers.php (Laravel 11+)
return [
    Bluecapapps\DownctlLaravel\DownctlServiceProvider::class,
];

// config/app.php (Laravel 10)
'providers' => [
    Bluecapapps\DownctlLaravel\DownctlServiceProvider::class,
],
bash
php artisan vendor:publish --tag=downctl-config
ini
DOWNCTL_API_KEY=your-secret-api-key
bash
php artisan downctl:test
ini
DOWNCTL_CAPTURE_LEVEL=error
ini
DOWNCTL_CAPTURE_LEVEL=warning
ini
DOWNCTL_CAPTURE_LEVEL=
ini
DOWNCTL_QUEUE=true
bash
php artisan downctl:crons:sync