PHP code example of understand / understand-laravel

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

    

understand / understand-laravel example snippets


Understand\UnderstandLaravel5\UnderstandLaravel5ServiceProvider::class,

UNDERSTAND_ENABLED=true
UNDERSTAND_TOKEN=your-input-token-from-understand-io
 
// anywhere inside your Laravel app
\Log::error('Understand.io test error');
 
\Log::info('my message', ['my_custom_field' => 'my data']);

# Specify which handler to use - sync, queue or async. 
# 
# Note that the async handler will only work in systems where 
# the CURL command line tool is installed
UNDERSTAND_HANDLER=async

  public function report(Exception $e)
  {
      \UnderstandExceptionLogger::log($e);

      return parent::report($e);
  }
  

// app/Logging/UnderstandLogFilter.php


declare(strict_types=1);

namespace App\Logging;

use Illuminate\Support\Str;

class UnderstandLogFilter
{
    public function __invoke($level, $message, $context): bool
    {
        if ($level === 'warning' && Str::contains(strtolower($message), 'deprecated')) {
            return true;
        }

        return false;
    }
}


// ...
// config/understand-laravel.php
'log_filter' => \App\Logging\UnderstandLogFilter::class,

php artisan vendor:publish --provider="Understand\UnderstandLaravel5\UnderstandLaravel5ServiceProvider"