PHPackages                             saeedvir/laravel-profile-provider - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. saeedvir/laravel-profile-provider

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

saeedvir/laravel-profile-provider
=================================

Laravel package to profile and analyze service provider performance with timing, memory usage and diagnostic analysis

v1.0.0(6mo ago)24MITPHPPHP ^8.1CI failing

Since Dec 28Pushed 6mo agoCompare

[ Source](https://github.com/saeedvir/LaravelProfileProvider)[ Packagist](https://packagist.org/packages/saeedvir/laravel-profile-provider)[ Docs](https://github.com/saeedvir/LaravelProfileProvider)[ RSS](/packages/saeedvir-laravel-profile-provider/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (5)Versions (2)Used By (0)

Laravel Profile Provider
========================

[](#laravel-profile-provider)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1a26bde5ecea79ad43b3f14c2d079778ce3dc738ef21ee6b16e2b14bfffb1ea3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73616565647669722f6c61726176656c2d70726f66696c652d70726f76696465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/saeedvir/laravel-profile-provider)[![Total Downloads](https://camo.githubusercontent.com/2709c06e745d370d7d28743fc2735933e5b209ffda52c7172d6bf37d797b235d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616565647669722f6c61726176656c2d70726f66696c652d70726f76696465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/saeedvir/laravel-profile-provider)[![License](https://camo.githubusercontent.com/4e8e300963031dd29950b7b031eae49afe537116af6cb56d7e35d9e8c410b4db/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73616565647669722f6c61726176656c2d70726f66696c652d70726f76696465722e7376673f7374796c653d666c61742d737175617265)](https://github.com/saeedvir/LaravelProfileProvider/blob/main/LICENSE)

A powerful Laravel package to profile and analyze service provider performance with detailed timing, memory usage, and diagnostic analysis. Identify bottlenecks in your Laravel application's boot process and optimize service provider performance.

Features
--------

[](#features)

- 📊 **Detailed Timing Analysis** - Separate timing for registration and boot phases
- 💾 **Memory Usage Tracking** - Monitor memory consumption per provider
- 🚦 **Diagnostic Analysis** - Detect common performance issues (filesystem operations, HTTP calls, database queries, etc.)
- 📈 **Comparison Mode** - Compare current run with previous runs to track performance changes
- 🔄 **Parallel Boot Estimation** - Estimate potential speedup with parallel provider loading
- 📤 **Multiple Export Formats** - Export results in JSON, CSV, or formatted tables
- 🎨 **Color-Coded Output** - Visual highlighting of slow providers and performance issues
- 🔍 **Dependency Analysis** - Analyze provider dependencies and their impact
- ⚡ **Performance Recommendations** - Get actionable suggestions to optimize your application
- 🎯 **Deferred Provider Detection** - Identify which providers are deferred and which should be

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require saeedvir/laravel-profile-provider --dev
```

The package will automatically register its service provider.

Configuration
-------------

[](#configuration)

Optionally, publish the configuration file:

```
php artisan vendor:publish --provider="Saeedvir\LaravelProfileProvider\LaravelProfileProviderServiceProvider"
```

This will create a `config/profile-provider.php` file with the following options:

```
return [
    // Default threshold in seconds for marking providers as slow
    'threshold' => 0.01,

    // Default number of top slowest providers to display
    'top' => 20,

    // Default field to sort providers by (total, register, boot, memory)
    'sort' => 'total',

    // How many hours to keep previous run data for comparison
    'cache_ttl_hours' => 24,

    // Maximum length for provider names in output tables
    'max_provider_name_length' => 50,
];
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Run the profiler with default settings:

```
php artisan profile:providers
```

This will display a table showing all service providers with their registration time, boot time, total time, and diagnostic information.

### Common Use Cases

[](#common-use-cases)

#### 1. Find the Slowest Providers

[](#1-find-the-slowest-providers)

Show only the top 10 slowest providers:

```
php artisan profile:providers --top=10
```

#### 2. Track Memory Usage

[](#2-track-memory-usage)

Include memory consumption analysis:

```
php artisan profile:providers --memory
```

#### 3. Compare Performance Over Time

[](#3-compare-performance-over-time)

Compare current run with the previous run to track performance changes:

```
php artisan profile:providers --compare
```

#### 4. Export Results

[](#4-export-results)

Export results to a JSON file for further analysis:

```
php artisan profile:providers --format=json --export=storage/profiling/results.json
```

Export to CSV:

```
php artisan profile:providers --format=csv --export=storage/profiling/results.csv
```

#### 5. Focus on Specific Threshold

[](#5-focus-on-specific-threshold)

Only show providers slower than 50ms:

```
php artisan profile:providers --threshold=0.05
```

#### 6. Sort by Different Metrics

[](#6-sort-by-different-metrics)

Sort by registration time:

```
php artisan profile:providers --sort=register
```

Sort by boot time:

```
php artisan profile:providers --sort=boot
```

Sort by memory usage:

```
php artisan profile:providers --sort=memory --memory
```

#### 7. Estimate Parallel Boot Performance

[](#7-estimate-parallel-boot-performance)

See potential speedup with parallel provider loading:

```
php artisan profile:providers --parallel
```

#### 8. Dry Run (Simulation)

[](#8-dry-run-simulation)

Simulate profiling without actual execution (useful for testing):

```
php artisan profile:providers --dry-run
```

#### 9. Profile Cached Providers

[](#9-profile-cached-providers)

Profile only providers from the bootstrap cache:

```
php artisan profile:providers --use-cache
```

Or profile exclusively cached providers:

```
php artisan profile:providers --only-cached
```

#### 10. Skip Diagnostics

[](#10-skip-diagnostics)

For faster profiling without diagnostic analysis:

```
php artisan profile:providers --no-diagnostics
```

### Advanced Usage Examples

[](#advanced-usage-examples)

#### Complete Performance Analysis

[](#complete-performance-analysis)

```
php artisan profile:providers \
    --top=15 \
    --threshold=0.01 \
    --memory \
    --compare \
    --parallel \
    --export=storage/profiling/analysis-$(date +%Y%m%d).json
```

#### Quick Check for Slow Providers

[](#quick-check-for-slow-providers)

```
php artisan profile:providers --top=5 --threshold=0.1 --no-diagnostics
```

#### Detailed Analysis with All Features

[](#detailed-analysis-with-all-features)

```
php artisan profile:providers \
    --memory \
    --compare \
    --parallel \
    --sort=total \
    --format=table
```

Available Options
-----------------

[](#available-options)

OptionDescriptionDefault`--top=N`Show top N slowest providers20`--threshold=N`Mark providers slower than N seconds0.01`--sort=FIELD`Sort by: total, register, boot, memorytotal`--format=FORMAT`Output format: table, json, csvtable`--export=PATH`Save results to file-`--compare`Compare with previous runfalse`--memory`Include memory usage trackingfalse`--no-diagnostics`Skip diagnostic analysisfalse`--use-cache`Read providers from bootstrap cachefalse`--dry-run`Simulate profiling without executionfalse`--only-cached`Profile only cached providersfalse`--parallel`Estimate parallel boot timingfalseUnderstanding the Output
------------------------

[](#understanding-the-output)

### Table Output

[](#table-output)

The default table output includes:

- **Provider**: The fully qualified class name of the service provider
- **Register(s)**: Time taken during the registration phase
- **Boot(s)**: Time taken during the boot phase
- **Total(s)**: Combined registration and boot time
- **Type**: Shows "DEFERRED" if the provider is deferred
- **Status**: Shows "SLOW" if the provider exceeds the threshold
- **Memory**: Memory consumption (when `--memory` is used)
- **Diagnostics**: Detected performance patterns (filesystem, http, database, etc.)
- **Errors**: Any errors encountered during profiling

### Summary Statistics

[](#summary-statistics)

The summary section provides:

- Total number of providers
- Successful vs failed providers
- Number of deferred providers
- Count of slow providers
- Total boot time
- Average and median times
- Memory statistics (when enabled)
- Percentile distribution (P50, P75, P90, P95, P99, P100)

### Diagnostic Patterns

[](#diagnostic-patterns)

The profiler detects the following patterns:

- **filesystem**: File operations (File::allFiles, glob, Storage)
- **http**: HTTP requests (Http, GuzzleHttp, curl)
- **config**: Configuration access
- **container**: Container bindings and resolutions
- **database**: Database queries (DB, Eloquent, Schema)
- **cache**: Cache operations
- **event**: Event listeners and dispatchers
- **queue**: Queue operations
- **broadcast**: Broadcasting operations
- **mail**: Mail operations
- **notification**: Notification operations
- **session**: Session operations
- **validation**: Validation operations
- **view**: View operations
- **route**: Route operations
- **auth**: Authentication operations
- **log**: Logging operations
- **redis**: Redis operations
- **artisan**: Artisan command operations
- **count\_in\_loop**: Performance anti-pattern
- **potential\_n1\_query**: Potential N+1 query issues

### Recommendations

[](#recommendations)

The profiler provides actionable recommendations such as:

- ⚡ Consider optimizing/deferring slow providers
- 🔁 Found count() in loops - consider caching counts
- ⏱️ Consider making more providers deferred if possible
- 🎯 Focus optimization on top slow providers (Pareto principle)

Practical Examples
------------------

[](#practical-examples)

### Example 1: Identifying Slow Providers in Production

[](#example-1-identifying-slow-providers-in-production)

```
# Profile with memory tracking and export results
php artisan profile:providers \
    --memory \
    --threshold=0.05 \
    --export=storage/logs/provider-profile.json
```

### Example 2: Continuous Performance Monitoring

[](#example-2-continuous-performance-monitoring)

```
# Compare with previous run to track regressions
php artisan profile:providers \
    --compare \
    --top=20 \
    --memory
```

### Example 3: Optimizing Application Boot Time

[](#example-3-optimizing-application-boot-time)

```
# Get detailed analysis with parallel estimation
php artisan profile:providers \
    --parallel \
    --memory \
    --sort=total \
    --top=10
```

### Example 4: Debugging Specific Performance Issues

[](#example-4-debugging-specific-performance-issues)

```
# Focus on providers with database operations
php artisan profile:providers \
    --memory \
    --format=json | jq '.providers | to_entries[] | select(.value.diagnostics | contains(["database"]))'
```

Best Practices
--------------

[](#best-practices)

1. **Run in Development**: This package is intended for development and should be installed with `--dev`
2. **Regular Profiling**: Profile your application regularly to catch performance regressions early
3. **Compare Runs**: Use `--compare` to track performance changes over time
4. **Focus on Top Offenders**: Use `--top=10` to focus on the most impactful providers
5. **Export Results**: Export results for historical tracking and analysis
6. **Consider Deferring**: Look for providers that can be deferred to speed up boot time
7. **Memory Tracking**: Use `--memory` when investigating memory issues
8. **Parallel Estimation**: Use `--parallel` to understand potential speedup opportunities

Performance Tips
----------------

[](#performance-tips)

Based on the profiler's output, consider these optimization strategies:

1. **Defer Providers**: Make providers deferred when their services aren't needed on every request
2. **Lazy Loading**: Avoid loading resources during registration/boot that can be loaded on-demand
3. **Cache Configuration**: Cache configuration values instead of reading files repeatedly
4. **Optimize Database Queries**: Move database queries out of the boot process
5. **Avoid HTTP Calls**: Never make HTTP requests during provider registration/boot
6. **Minimize File Operations**: Reduce filesystem operations during boot
7. **Use Singleton Bindings**: Use singleton bindings for services that should be instantiated once

Troubleshooting
---------------

[](#troubleshooting)

### No Providers Found

[](#no-providers-found)

If you see "No providers found", ensure:

- Your application has registered providers in `config/app.php` or `bootstrap/providers.php`
- You're running the command from your Laravel application root
- The cache is cleared: `php artisan config:clear`

### High Memory Usage

[](#high-memory-usage)

If profiling causes high memory usage:

- Use `--no-diagnostics` to skip diagnostic analysis
- Use `--top=N` to limit the number of providers analyzed
- Profile in batches using `--only-cached` and without cache

### Inaccurate Timings

[](#inaccurate-timings)

For more accurate timings:

- Run the profiler multiple times and compare results
- Avoid running other processes during profiling
- Use `--compare` to track trends rather than absolute values

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Saeed Abdollahian](https://github.com/saeedvir)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Support
-------

[](#support)

If you find this package helpful, please consider:

- ⭐ Starring the repository
- 🐛 Reporting bugs
- 💡 Suggesting new features
- 📖 Improving documentation
- 🔀 Contributing code

Related Packages
----------------

[](#related-packages)

- [Laravel Debugbar](https://github.com/barryvdh/laravel-debugbar) - Debug bar for Laravel
- [Laravel Telescope](https://laravel.com/docs/telescope) - Debug assistant for Laravel
- [Clockwork](https://github.com/itsgoingd/clockwork) - Development tools for PHP

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance68

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

189d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8615309?v=4)[saeed abdollahian](/maintainers/saeedvir)[@saeedvir](https://github.com/saeedvir)

---

Top Contributors

[![saeedvir](https://avatars.githubusercontent.com/u/8615309?v=4)](https://github.com/saeedvir "saeedvir (3 commits)")

---

Tags

laravellaravel-packageoptimizationpackagelaravelperformanceservice provideroptimizationprofile

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/saeedvir-laravel-profile-provider/health.svg)

```
[![Health](https://phpackages.com/badges/saeedvir-laravel-profile-provider/health.svg)](https://phpackages.com/packages/saeedvir-laravel-profile-provider)
```

###  Alternatives

[laravel/sail

Docker files for running a basic Laravel application.

1.9k205.7M1.3k](/packages/laravel-sail)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M203](/packages/laravel-ai)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M167](/packages/spatie-laravel-health)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)

PHPackages © 2026

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