PHP code example of edquint / sql-logger

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

    

edquint / sql-logger example snippets


use SqlLogger\Settings\LoggerConfig;

LoggerConfig::setLogPath(__DIR__ . '/logs'); // Path where logs will be saved
LoggerConfig::setFileName('queries.log');    // Log file name

use SqlLogger\LogSql;

// Example with an ORM query (Doctrine, Eloquent, etc.)
LogSql::orm($query);

// Alternatively, using the global helper function
sql_logger($query);

use SqlLogger\LogSql;

$params = ['id' => 10];
$sql = "SELECT * FROM users WHERE id = :id";

LogSql::raw($sql, $params);

// Alternatively, using the global helper function
sql_logger($sql, $params);

[2025-08-02 19:00:00] Sql Query:
SELECT
  *
FROM
  users
WHERE
  id = 10