PHP code example of baklysystems / app-watch-laravel-client

1. Go to this page and download the library: Download baklysystems/app-watch-laravel-client 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/ */

    

baklysystems / app-watch-laravel-client example snippets


use Appswatch;

// Log a custom event
Appswatch::log('info', 'User signed up', ['user_id' => 42]);

// Capture an exception manually
try {
    riskyOperation();
} catch (\Throwable $e) {
    Appswatch::exception($e, ['user_id' => $userId]);
}

// Send a custom metric
Appswatch::metric('users.signed_up', 1, 'count', ['plan' => 'pro']);

use BaklySystems\AppWatch\Middleware\AppswatchJobMiddleware;

class MyJob implements ShouldQueue
{
    public function middleware(): array
    {
        return [new AppswatchJobMiddleware];
    }
}

use BaklySystems\AppWatch\Collectors\MetricCollector;

MetricCollector::counter('orders.placed', 1, 'count', ['channel' => 'web']);
MetricCollector::gauge('users.active', 150, 'count', ['plan' => 'pro']);
MetricCollector::histogram('api.response_time_ms', 42.5, 'ms', ['endpoint' => '/api/users']);
bash
php artisan vendor:publish --tag=appswatch-config