askerakbar / lens
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
Requires
- laminas-api-tools/api-tools-asset-manager: 1.8.x-dev
- laminas/laminas-cli: ^1.11
- laminas/laminas-component-installer: ^3.0
- laminas/laminas-modulemanager: ^2.14
- laminas/laminas-mvc: ^3.5
Requires (Dev)
- pestphp/pest: 3.x-dev
Suggests
- laminas/laminas-cli: Required to use the lens:publish-migration command and other CLI features.
README
A sleek, simple, and developer-friendly SQL query logger for Laminas MVC applications.
Quick Start
-
Install via Composer
composer require askerakbar/lens --dev
-
Register the module (if not auto-discovered): Add to
config/modules.config.php
:AskerAkbar\Lens
-
Run the migration to create the database table (see Storage).
-
Access the UI by visiting
/lens
in your browser.
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
-
Publish migration:
vendor/bin/laminas lens:publish-migration # Optional target directory: vendor/bin/laminas lens:publish-migration --target=database/migrations
-
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.