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
Snapshot Profiler Contracts

Snapshot Profiler Contracts Laravel Package

aeatech/snapshot-profiler-contracts

Contracts/interfaces for integrating a snapshot-based profiler into Laravel/PHP apps. Provides the core abstractions used by the Snapshot Profiler package ecosystem for capturing, storing, and reporting performance snapshots across implementations.

View on GitHub
Deep Wiki
Context7

The package contains a set of interfaces for implementing profiling applications

Frequently asked questions about Snapshot Profiler Contracts
What Laravel versions does this package support?
This package requires PHP 8.2+ and is designed for Laravel 9/10. While it may work with older Laravel versions, test thoroughly for compatibility with attributes, enums, or modern PHP features used in your implementation.
How do I integrate this with an existing profiler like Blackfire or XHProf?
Implement the `AdapterInterface` to bridge your profiler’s data with the contracts. For example, wrap Blackfire’s output in a class adhering to `ProfilerInterface` and register it in Laravel’s service container via `AppServiceProvider`.
Can I use this for async profiling (e.g., Laravel queues)?
The contracts don’t natively support async profiling, but you can extend `ProfilerInterface` to include event-driven methods. Use Laravel’s `dispatch()` or queue listeners to trigger profiling after job completion.
What’s the minimal setup to start profiling in Laravel?
Bind the `ProfilerInterface` to a custom implementation in `AppServiceProvider`, then wrap critical code with `start()`/`snapshot()`/`store()` calls. Example: `$profiler->start('route.handler'); // ... $profiler->snapshot()->store();`
How do I store profiling snapshots (e.g., database, cache)?
Implement `SaverInterface` to define storage logic. For databases, use Eloquent models; for cache, leverage Laravel’s `Cache` facade. Register your saver in the container to handle snapshot persistence.
Will this impact production performance if always enabled?
Yes, profiling adds overhead. Use environment-based toggles (e.g., `config('profiling.enabled')`) or middleware to disable it in production. Consider sampling snapshots for high-traffic apps.
Are there built-in filters for profiling data?
Yes, implement `FilterInterface` to customize snapshot data before storage. For example, exclude internal routes or sanitize sensitive query parameters. Combine multiple filters via dependency injection.
How do I test this package in PHPUnit?
Mock the `ProfilerInterface` and `SaverInterface` in tests. Verify snapshot data with assertions like `assertEquals(100, $snapshot->getDurationMs())`. Use Laravel’s `Mockery` or PHPUnit’s built-in mocking.
What alternatives exist for Laravel profiling?
Consider Laravel Telescope (built-in), Blackfire (commercial), or Xdebug (debugging). This package differs by providing *contracts*—ideal if you need custom implementations or want to avoid vendor lock-in.
How do I handle profiling failures (e.g., storage errors)?
Implement `ExceptionInterface` in your saver/profiler to catch failures. Log errors via Laravel’s `Log` facade or notify via `notify()` with a custom `Notification`. Default to silent degradation or alerts.
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity