定制 askerakbar/lens 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

askerakbar/lens

最新稳定版本:0.0.4

Composer 安装命令:

composer require askerakbar/lens

包简介

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

README 文档

README

A sleek, simple, 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
  2. Run the migration:

    • SQL migration: Execute the generated SQL file using your preferred method
    • Doctrine migration: Run vendor/bin/doctrine-migrations migrate (if using Doctrine)

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.

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-27