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 integrating XHProf profiling into your app. Capture and review performance data for requests, analyze bottlenecks, and compare runs to optimize code, queries, and overall response time with minimal setup and overhead.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Performance Optimization Roadmap: Prioritize technical debt reduction by quantifying bottlenecks (e.g., "Profiling reveals 40% of API latency stems from Eloquent N+1 queries—allocate sprint capacity to implement eager loading").
  • Build vs. Buy Decision: Replace a custom-built profiling system (requiring 6–12 months of dev effort and ongoing maintenance) with a zero-maintenance, Laravel-native package that integrates seamlessly into existing workflows.
  • Non-Functional Requirements (NFRs): Enforce performance SLAs in CI/CD pipelines (e.g., "API must respond under 500ms") by failing tests on deviations, reducing runtime failures in production.
  • Developer Productivity: Reduce debugging time for slow endpoints by 90%, enabling developers to diagnose bottlenecks in minutes (e.g., "Add ?profile=1 to any route to instantly visualize wall time, memory usage, and call graphs").
  • Cost Efficiency: Eliminate $20K/year in enterprise APM tooling (e.g., New Relic) during development while maintaining full visibility into critical bottlenecks.
  • Scalable Profiling: Support CLI jobs, queues, and background tasks alongside web requests, ensuring optimizations are applied across the entire stack (e.g., "Profiling shows a CLI job processing 10K records takes 2 hours—optimize to 10 minutes").
  • Regression Prevention: Implement branch comparison workflows to catch performance regressions before they reach production (e.g., "Flame graph shows a 30% increase in wall time for /orders in the feature/payment branch—block merge until optimized").
  • Data-Driven Technical Debt Management: Shift from anecdotal tuning to evidence-based optimizations by identifying top CPU/memory consumers (e.g., "Top 3 bottlenecks: Redis serialization (25%), queue workers (20%), Eloquent hydration (15%)").

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 2 minutes (just append ?profile=1 to any URL) instead of hours of trial-and-error debugging. Example: "Identified and fixed a 500ms 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., "30% 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 10 minutes, saving $5K/month in queue workers").

Ask: "Would you prefer to spend $20K/year on APM tools or invest 2 hours 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, not just high-level metrics.

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 pipeline (e.g., fail if response time > 500ms).
  3. Team Training: 1-hour workshop on interpreting flame graphs and optimizing bottlenecks.
  4. Scale: Roll out to CLI jobs and queues in 2 sprints.

Ask: "Should we allocate 2 hours to set this up and start catching performance issues before they impact users?"


For Developers:

"This package makes profiling effortless—here’s how it fits into your workflow:

  • Web Requests: Append ?profile=1 to any URL to see a flame graph of execution time, memory usage, and function calls.
  • CLI Jobs: Wrap your job logic with Xhprof::start() and Xhprof::stop() to profile background tasks.
  • Tests: Enforce performance SLAs in tests (e.g., assertLessThan(500, $profile->getWallTime())).
  • Zero Setup: Just install via Composer, publish migrations, and enable the middleware.

Why It’s Better Than Alternatives:

  • No External Tools: Unlike Blackfire or Tideways, this runs locally with no subscription.
  • Laravel-First: Built for Laravel’s middleware, routes, and Artisan commands.
  • Lightweight: Only profile what you need (skip routes, gate by environment).

Example Workflow:

  1. User reports /api/orders is slow.
  2. Append ?profile=1 to the URL.
  3. See a flame graph showing Order::with('items')->get() takes 400ms.
  4. Optimize with eager loading: Order::with(['items' => fn($q) => $q->limit(10)])->get().
  5. Re-profile to confirm the fix.

Ask: "Want to spend 10 minutes setting this up and save hours of debugging time?"

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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope