PHPackages                             icw-kb/laminas-microscope - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. icw-kb/laminas-microscope

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

icw-kb/laminas-microscope
=========================

A comprehensive debugging and profiling suite for Laminas applications

0102PHP

Since Jun 7Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/icw-kb/laminas-microscope)[ Packagist](https://packagist.org/packages/icw-kb/laminas-microscope)[ RSS](/packages/icw-kb-laminas-microscope/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Laminas Microscope 🔬
====================

[](#laminas-microscope-)

A comprehensive debugging and profiling suite for Laminas applications that provides deep insights into your application's performance, database queries, and potential issues.

[![PHP Version](https://camo.githubusercontent.com/6518db1335bf20fdff07253dc6d6d0cec955b5fb6a8ef1382ac6d73687ecc07f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c7565)](https://php.net)[![Laminas Version](https://camo.githubusercontent.com/b0e30628a3d09e3dfd56498bbf35a6bafa8c40af0c1073d3d5b2081bd8c292bb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c616d696e61732d253345253344332e302d677265656e)](https://getlaminas.org)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

✨ Features
----------

[](#-features)

### 🎯 **Core Components**

[](#-core-components)

- **🔬 Microscope Analysis** - Advanced code analysis with N+1 query detection and performance profiling
- **📊 Debug Bar** - Real-time request profiling with database query logging and memory tracking
- **💥 Whoops Integration** - Beautiful error pages with detailed stack traces and debugging info
- **⚙️ Configuration Management** - Easy configuration with environment profiles and presets

### 📈 **Analysis Capabilities**

[](#-analysis-capabilities)

- **Database Query Analysis** - Slow query detection, duplicate query identification, N+1 problem detection
- **Performance Profiling** - Request timeline, memory usage tracking, bottleneck identification
- **Route Analysis** - Route performance metrics, hit counting, response time tracking
- **Issue Detection** - Automated detection of common performance and coding issues

### 🛠️ **Debug Bar Collectors**

[](#️-debug-bar-collectors)

- **⏱️ Time Collector** - Request duration, bootstrap time, component timing
- **💾 Memory Collector** - Memory usage tracking with peak usage alerts
- **🗄️ PDO Collector** - SQL query logging with parameter binding and performance metrics
- **🌐 Request Collector** - HTTP request/response data, headers, parameters
- **⚙️ Config Collector** - Application configuration, module info, service manager data
- **📨 Messages Collector** - Custom logging and timeline events

🚀 Quick Start
-------------

[](#-quick-start)

### Installation

[](#installation)

```
composer require icw-kb/laminas-microscope --dev
```

### Basic Setup

[](#basic-setup)

1. **Copy main configuration:**

```
cp vendor/icw-kb/laminas-microscope/config/laminas-microscope.local.php config/autoload/
```

2. **Add module to your application:**

```
// config/modules.config.php
return [
    'Laminas\Router',
    'Laminas\Validator',
    // ... your modules
    'LaminasMicroscope', // Add this line
];
```

3. **Configure for your environment:**

```
# config/autoload/laminas-microscope.local.php
return [
    'laminas_microscope' => [
        'enabled' => true,
        'environment' => 'development',
        'components' => [
            'whoops' => ['enabled' => true],
            'debug_bar' => ['enabled' => true],
            'microscope' => ['enabled' => true],
        ],
    ],
];
```

### Access the Debug Suite

[](#access-the-debug-suite)

Visit `http://your-app.com/_debug` to access the debug dashboard.

📖 Detailed Documentation
------------------------

[](#-detailed-documentation)

### 🔧 Configuration

[](#-configuration)

#### Environment-Specific Configuration

[](#environment-specific-configuration)

Create environment-specific configuration files:

```
# Copy environment templates
mkdir -p config/autoload/debug-suite
cp vendor/icw-kb/laminas-microscope/config/environments/* config/autoload/debug-suite/
cp vendor/icw-kb/laminas-microscope/config/profiles/* config/autoload/debug-suite/
```

#### Configuration Profiles

[](#configuration-profiles)

**Minimal Profile** (Production-safe):

```
laminas_microscope:
  enabled: true
  components:
    whoops:
      enabled: true
      show_in_production: false
    debug_bar:
      enabled: false
    microscope:
      enabled: false
```

**Performance Profile** (Staging):

```
laminas_microscope:
  enabled: true
  collectors: ['time', 'memory', 'pdo']
  components:
    whoops:
      enabled: false
    debug_bar:
      enabled: true
      collectors_only: true
    microscope:
      enabled: true
      auto_analyze: true
```

**Full Debugging Profile** (Development):

```
laminas_microscope:
  enabled: true
  collectors: ['time', 'memory', 'exceptions', 'pdo', 'request', 'config', 'messages']
  components:
    whoops:
      enabled: true
    debug_bar:
      enabled: true
      collectors_only: true
    microscope:
      enabled: true
      auto_analyze: true
      checks:
        n_plus_one: true
        slow_queries: true
        duplicate_queries: true
```

### 📊 Debug Bar Usage

[](#-debug-bar-usage)

The Debug Bar automatically appears at the bottom of HTML pages and shows:

- **Request timing** and performance breakdown
- **Memory usage** with peak tracking
- **Database queries** with execution time and parameters
- **HTTP request/response** details
- **Configuration** data and environment info
- **Custom messages** and timeline events

#### Programmatic Usage

[](#programmatic-usage)

```
// Add custom timing
$debugBar = $container->get('LaminasMicroscope\DebugBar\DebugBarHandler');
$debugBar->startMeasure('my_operation', 'My Custom Operation');
// ... your code ...
$debugBar->stopMeasure('my_operation');

// Add custom messages
$debugBar->addMessage('Processing started', 'info');
$debugBar->addMessage('Warning: High memory usage', 'warning');

// Log exceptions
try {
    // risky code
} catch (\Exception $e) {
    $debugBar->addException($e);
}
```

### 🔬 Microscope Analysis

[](#-microscope-analysis)

#### Automated Analysis

[](#automated-analysis)

Enable auto-analysis to automatically detect issues:

```
laminas_microscope:
  components:
    microscope:
      enabled: true
      auto_analyze: true
      thresholds:
        query_time: 100  # ms
        memory_usage: 50 # MB
      checks:
        n_plus_one: true
        slow_queries: true
        duplicate_queries: true
        memory_leaks: true
```

#### Manual Analysis

[](#manual-analysis)

Access the main debug interface at `/_debug` to:

- **Run analysis** on demand via the Analytics and Performance tabs
- **View query reports** with performance metrics
- **Analyze routes** and their performance
- **Review detected issues** with suggestions
- **Export reports** for team sharing

#### Issue Detection

[](#issue-detection)

The Microscope automatically detects:

- **N+1 Query Problems** - Queries executed in loops
- **Slow Queries** - Queries exceeding threshold
- **Duplicate Queries** - Identical queries run multiple times
- **Memory Leaks** - Excessive memory usage patterns
- **Route Bottlenecks** - Slow-performing routes

### 💥 Whoops Integration

[](#-whoops-integration)

Beautiful error pages with:

- **Detailed stack traces** with syntax highlighting
- **Request/response data** for debugging context
- **Environment information** and configuration
- **Code editor integration** (VS Code, PhpStorm, Sublime)

```
laminas_microscope:
  components:
    whoops:
      enabled: true
      editor: 'vscode'  # 'phpstorm', 'sublime'
      show_in_production: false
```

🎛️ Advanced Configuration
-------------------------

[](#️-advanced-configuration)

### Security Settings

[](#security-settings)

```
laminas_microscope:
  enabled: true
  ip_whitelist:
    - '127.0.0.1'
    - '192.168.1.0/24'
    - '::1'
  storage:
    path: '/tmp/laminas-microscope'
    retention_days: 30
```

### Custom Collectors

[](#custom-collectors)

Create custom debug bar collectors:

```
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\Renderable;

class MyCustomCollector extends DataCollector implements Renderable
{
    public function collect(): array
    {
        return [
            'my_data' => 'custom information',
            'count' => 42
        ];
    }

    public function getName(): string
    {
        return 'my_custom';
    }

    public function getWidgets(): array
    {
        return [
            'my_custom' => [
                'icon' => 'gear',
                'widget' => 'PhpDebugBar.Widgets.VariableListWidget',
                'map' => 'my_custom',
                'default' => '{}'
            ]
        ];
    }
}
```

Register in your service manager:

```
// In your module's service configuration
'service_manager' => [
    'factories' => [
        MyCustomCollector::class => function($container) {
            return new MyCustomCollector();
        },
    ],
],
```

### Event Integration

[](#event-integration)

Listen for debug events:

```
use Laminas\EventManager\EventManagerInterface;
use LaminasMicroscope\Event\AnalysisEvent;

class MyListener
{
    public function attach(EventManagerInterface $events): void
    {
        $events->attach('laminas-microscope.analysis.complete', [$this, 'onAnalysisComplete']);
    }

    public function onAnalysisComplete(AnalysisEvent $e): void
    {
        $report = $e->getReport();
        // Handle analysis completion
    }
}
```

🔧 Troubleshooting
-----------------

[](#-troubleshooting)

### Common Issues

[](#common-issues)

**1. Debug Bar not appearing:**

- Check that `laminas_microscope.components.debug_bar.enabled` is `true`
- Ensure your response is HTML content-type
- Verify the closing `` tag exists in your HTML

**2. Storage permission errors:**

- Check write permissions on storage path
- Default: `/tmp/laminas-microscope`
- Configure custom path in configuration

**3. Whoops not showing:**

- Verify `whoops.enabled` is `true`
- Check environment settings
- Ensure error reporting is enabled

**4. Performance Impact:**

- Use minimal profile in production
- Disable auto-analysis in high-traffic environments
- Configure IP whitelist for security

### Debug Mode

[](#debug-mode)

Enable verbose logging:

```
laminas_microscope:
  debug: true
  log_level: 'debug'
  log_file: '/tmp/laminas-microscope-debug.log'
```

📊 Performance Impact
--------------------

[](#-performance-impact)

ComponentCPU ImpactMemory ImpactRecommended UseWhoopsMinimalLowAll environmentsDebug BarLowMediumDevelopment/StagingMicroscopeMediumMedium-HighDevelopmentFull SuiteMediumHighDevelopment only🤝 Contributing
--------------

[](#-contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Write tests for your changes
4. Ensure all tests pass (`composer test`)
5. Commit your changes (`git commit -m 'Add amazing feature'`)
6. Push to the branch (`git push origin feature/amazing-feature`)
7. Open a Pull Request

### Development Setup

[](#development-setup)

```
git clone https://github.com/icw-kb/laminas-microscope.git
cd laminas-microscope
composer install
composer test
```

📝 License
---------

[](#-license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

🆘 Support
---------

[](#-support)

- **Documentation**: [GitHub Wiki](https://github.com/icw-kb/laminas-microscope/wiki)
- **Issues**: [GitHub Issues](https://github.com/icw-kb/laminas-microscope/issues)
- **Discussions**: [GitHub Discussions](https://github.com/icw-kb/laminas-microscope/discussions)

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- Built on top of [maximebf/php-debug-bar](https://github.com/maximebf/php-debug-bar)
- Inspired by [barryvdh/laravel-debugbar](https://github.com/barryvdh/laravel-debugbar)
- Uses [filp/whoops](https://github.com/filp/whoops) for error handling

---

**Made with ❤️ for the Laminas community**

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7900a6b66b1d2e5e4006e4f5b4ab65eb7dd539d217d4533547ee522e0becc797?d=identicon)[icw-kb](/maintainers/icw-kb)

---

Top Contributors

[![zcwilt](https://avatars.githubusercontent.com/u/227354?v=4)](https://github.com/zcwilt "zcwilt (56 commits)")[![icw-kb](https://avatars.githubusercontent.com/u/207558366?v=4)](https://github.com/icw-kb "icw-kb (17 commits)")

### Embed Badge

![Health badge](/badges/icw-kb-laminas-microscope/health.svg)

```
[![Health](https://phpackages.com/badges/icw-kb-laminas-microscope/health.svg)](https://phpackages.com/packages/icw-kb-laminas-microscope)
```

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
