PHP code example of codelikesuraj / vanguard-php

1. Go to this page and download the library: Download codelikesuraj/vanguard-php 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/ */

    

codelikesuraj / vanguard-php example snippets




use Codelikesuraj\Vanguard\Vanguard;
use Codelikesuraj\Vanguard\Transport\FileTransport;

// log to local file
$transport = new FileTransport(__DIR__ . '/VANGUARD_LOG_FILE'));

/** OR **/

// log to Vanguard dashboard
$transport = new HttpTransport("https://VANGUARD_PROJECT_DSN")


// Initialize vanguard and automatically capture errors and exceptions
Vanguard::init($transport);

// Manually capture and exception
Vanguard::capture(Throwable $e, array $context = [])
    ->transport($transport)   // optional
json
{
  "context": [],
  "fingerprint": "24bb5912458f9dd1fe4bc1843a17c2c261306fff",
  "message": "strlen(): Argument #1 ($string) must be of type string, array given",
  "file": "/var/www/index.php",
  "line": 12,
  "stacktrace": [
    {"file": "/var/www/index.php", "line": 12, "function": "strlen"}
  ],
  "timestamp": "2025-08-17T20:11:49+01:00",
  "type": "TypeError"
}