PHP code example of itsemon245 / lamet

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

    

itsemon245 / lamet example snippets


    'lamet' => [
         'driver' => env('LAMET_DB_CONNECTION', 'pgsql'),
         'url' => env('LAMET_DATABASE_URL'),
         'host' => env('LAMET_DB_HOST', '127.0.0.1'),
         'port' => env('LAMET_DB_PORT', '5432'),
         'database' => env('LAMET_DB_DATABASE', 'lamet_metrics'),
         'username' => env('LAMET_DB_USERNAME', 'root'),
         'password' => env('LAMET_DB_PASSWORD', ''),
         'charset' => 'utf8',
         'prefix' => '',
         'prefix_indexes' => true,
         'search_path' => env('LAMET_DB_CONNECTION', 'pgsql') === 'pgsql' ? 'public' : null,
         'sslmode' => env('LAMET_DB_CONNECTION', 'pgsql') === 'pgsql' ? 'prefer' : null,
     ],
   

   protected function schedule(Schedule $schedule): void
   {
       $schedule->command('lamet:flush')->everyFiveMinutes();
   }
   

use Itsemon245\Lamet\Facades\Metrics;

// Record an API request
Metrics::increment('api.requests', 1, [
    'endpoint' => '/users',
    'method' => 'GET',
    'status_code' => 200
]);

protected function schedule(Schedule $schedule): void
{
    // Flush metrics every 5 minutes
    $schedule->command('lamet:flush')->everyFiveMinutes();

    // Clean old metrics daily at 2 AM (keep last 90 days)
    // $schedule->command('lamet:clean --days=90 --force')->dailyAt('02:00');
}
bash
   php artisan lamet:install
   
bash
   php artisan vendor:publish --tag=lamet-config
   php artisan vendor:publish --tag=lamet-migrations
   
bash
   php artisan migrate
   
bash
php artisan lamet:install
bash
php artisan lamet:flush
bash
php artisan lamet:clean