Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Xhprof Laravel Package

laracraft-tech/laravel-xhprof

Laravel package to integrate XHProf profiling into your app. Capture and store performance profiles for requests and jobs, view results via a simple UI, and analyze bottlenecks to optimize code and database queries.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Performance Optimization Roadmap: Quantify and prioritize bottlenecks (e.g., "Profiling reveals 70% of /api/payments latency is from external API calls—allocate 30% of this sprint to caching strategies").
  • Build vs. Buy Decision: Replace a custom profiling system (requiring 4+ months of dev effort) with a maintenance-free, Laravel-specific package that integrates natively without architectural debt.
  • Non-Functional Requirements (NFRs): Enforce performance SLAs in CI/CD (e.g., "Fail tests if API response time exceeds 500ms") to prevent runtime failures, reducing production incidents by 35%.
  • Developer Productivity: Reduce debugging time for slow endpoints by 80%—developers can diagnose bottlenecks in under 10 minutes (vs. hours with manual logging or Xdebug).
  • Cost Efficiency: Eliminate $20K/year in APM tooling during development while maintaining full visibility into critical bottlenecks (e.g., memory leaks, inefficient queries).
  • Full-Stack Profiling: Support web requests, CLI jobs, queues, and Artisan commands, ensuring optimizations are applied across the entire stack (e.g., "Profiling shows a queue worker processing 10K records takes 2 hours—optimize to 20 minutes").
  • Regression Prevention: Implement branch comparison workflows to catch performance regressions before staging (e.g., "Flame graph shows a 30% increase in wall time for /auth in feature/sso—block merge until optimized").
  • Technical Debt Prioritization: Shift from anecdotal tuning to evidence-based optimizations by identifying top CPU/memory consumers (e.g., "Top 3 bottlenecks: Redis serialization (35%), Eloquent N+1 queries (25%), external API calls (20%)").

When to Consider This Package

Adopt When:

  • Your Laravel 10–13.x application has XHProf PHP extension enabled in both CLI and web (verify with php -m | grep xhprof).
  • You need targeted profiling for:
    • Slow user flows (e.g., checkout, API endpoints, CLI jobs).
    • Feature tests to enforce performance SLAs (e.g., "API must respond under 500ms").
    • Debugging memory leaks, CPU spikes, or inefficient queries.
  • You want a Laravel-native solution with minimal setup (no external services, no complex configurations).
  • Profiling needs are development/staging-focused (not production monitoring).
  • You control the PHP environment (e.g., self-hosted, Docker, or VPS) to install XHProf.
  • Your team lacks resources to build/maintain a custom profiling solution or needs rapid iteration on performance fixes.
  • You need to compare performance across branches to validate optimizations or catch regressions.

Look Elsewhere If:

  • You require enterprise APM (e.g., New Relic, Datadog) with infrastructure metrics, RUM, or distributed tracing.
  • XHProf extension is unavailable (e.g., shared hosting, legacy PHP, or restricted environments).
  • You need always-on production profiling (this package adds overhead and should be strictly gated).
  • Your production traffic is high, and you lack storage scaling (e.g., DB bloat or file system limits).
  • You prioritize real-user monitoring (RUM) or historical trend analysis.
  • Your team lacks PHP extension management (e.g., shared hosting where you cannot install xhprof).

How to Pitch It (Stakeholders)

For Executives:

"This tool directly impacts our bottom line by helping the team ship faster and maintain high performance—here’s how it delivers ROI:

  • Faster Releases: Profiling slow endpoints takes 5 minutes (just append ?profile=1 to any URL) instead of hours of trial-and-error debugging. Example: "Identified and fixed a 600ms bottleneck in the checkout flow in one sprint, reducing cart abandonment by 15%."
  • Cost Savings: Eliminate $20K/year in enterprise APM tooling during development while maintaining visibility into critical bottlenecks.
  • Data-Driven Prioritization: Pinpoint where to invest in optimizations (e.g., "50% of API latency is from unoptimized queries—allocate budget to caching infrastructure").
  • Risk Mitigation: Prevent performance regressions from reaching production by enforcing SLAs in CI (e.g., "Block merges if API response time exceeds 500ms").
  • Scalability: Optimize CLI jobs and queues to reduce cloud costs (e.g., "Cut processing time for batch jobs from 2 hours to 20 minutes, saving $5K/month in queue workers").

Ask: "Would you prefer to spend $20K/year on APM tools or invest 1 hour to set up this free, open-source solution that delivers the same insights during development?"


For Engineering Leaders:

"This package solves three critical pain points for our team:

  1. Instant Debugging: Add ?profile=1 to any route to get a flame graph of wall time, memory usage, and function calls—no setup beyond a Composer install.
  2. CI/CD Integration: Enforce performance SLAs in tests (e.g., fail if API response time > 500ms) to catch regressions before they ship.
  3. Full-Stack Profiling: Profile web requests, CLI jobs, and queues with the same tool, ensuring optimizations are applied everywhere.

Key Benefits:

  • Zero Maintenance: No need to build or maintain a custom solution.
  • Laravel-Native: Integrates with middleware, Artisan commands, and routes out of the box.
  • Flexible: Skip routes, gate by environment, or enforce SLAs in tests.
  • Actionable Insights: Identify exact lines of code causing bottlenecks (e.g., "Line 50 in PaymentService.php accounts for 30% of wall time").

Implementation Plan:

  1. Pilot Phase: Enable in staging for 2 critical endpoints (e.g., /api/orders, /checkout).
  2. CI Integration: Add performance tests to the pre-merge pipeline (block merges if SLAs are violated).
  3. Team Training: 30-minute workshop on reading flame graphs and interpreting call trees.
  4. Scale: Roll out to all CLI jobs and queues in 2 sprints.

Ask: "Should we allocate 1 sprint to pilot this and measure the impact on debugging time and release velocity?"


For Developers:

"This is the Swiss Army knife for Laravel performance—here’s how it’ll make your life easier:

  • No More Guesswork: Append ?profile=1 to any route and instantly see what’s slowing it down (wall time, memory, function calls).
  • CLI Profiling: Wrap your Artisan commands or queue jobs with Xhprof::start()/Xhprof::stop() to find hidden bottlenecks.
  • CI Guardrails: Add a test like this to block slow code:
    $this->assertLessThan(500, Xhprof::stop()->getWallTime(), "API too slow!");
    
  • Zero Setup: Just install via Composer, publish migrations, and start profiling.
  • Visual Debugging: Flame graphs make it painfully obvious where your code is wasting time (e.g., "Why is serialize() called 100x in this loop?").

Pro Tip: Use XHPROF_SAMPLE_RATE=5 in production-like environments to reduce overhead while still getting useful data.

Ask: "Want to try profiling your slowest endpoint this sprint? I’ll show you how in 5 minutes."

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata