A sleek, developer-friendly SQL query logger for Laminas MVC applications.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:laminas-module

0.0.2 2025-07-27 18:22 UTC

This package is auto-updated.

Last update: 2025-07-27 18:47:35 UTC


README

A sleek, simple, and developer-friendly SQL query logger for Laminas MVC applications.

Quick Start

  1. Install via Composer

    composer require askerakbar/lens --dev
    
    
  2. Register the module (if not auto-discovered): Add to config/modules.config.php:

    AskerAkbar\Lens
  3. Run the migration to create the database table (see Storage).

  4. Access the UI by visiting /lens in your browser.

You'll see a dashboard like this: Laminas Lens UI Screenshot

Note: Database storage is enabled by default and requires the migration.

Features

  • Logs all executed DB queries
  • Displays SQL, parameters, timing, stack trace, and connection info
  • Search functionality
  • database-backed storage

Notes

This library has been tested only against:

  • Laminas MVC ^3.7.0
  • PHP 8.1 / 8.2 / 8.3
  • PDO_MySQL (MySQL / MariaDB)
  • Requires laminas/laminas-cli
  • Requires database connection to be configured

This tool is intended for development use only. Other DB backends, PHP, or other Laminas versions are untested and may not work as expected. if you find issues please feel free to make a PR.

Storage

Database Storage

Database storage is the default and requires a database table to be created. Configure your app config with the following in (config/autoload/global.php or local.php) if needed:

'lens' => [
    'storage' => [
        'type'  => 'database',
        'table' => 'lens_logs', // Optional, default: lens_logs
    ],
],

Running the Migration

  1. Publish migration:

    vendor/bin/laminas lens:publish-migration
    # Optional target directory:
    vendor/bin/laminas lens:publish-migration --target=database/migrations
  2. Run the migration: This generates a standard SQL file—execute it using your preferred method.

Troubleshooting

Xdebug: Segmentation Fault When Publishing Migrations

If you see errors like:

Cannot load Xdebug - it was already loaded
Xdebug: [Step Debug] Could not connect to debugging client...
Segmentation fault (core dumped)

Disable Xdebug for the session:

export XDEBUG_MODE=off
vendor/bin/laminas lens:publish-migration --target=database/migrations

License

MIT License. See License.md for details.