- How do I install spatie/flare-client-php in a Laravel project?
- Use Composer to install the package with `composer require spatie/flare-client-php`. For Laravel-specific integrations (like Ignition support), prefer `spatie/laravel-flare` instead. This package is framework-agnostic and works in any PHP 8.2+ app.
- What Laravel versions does this package support?
- This package is framework-agnostic and works with any Laravel 8.x+ or 9.x+ project. It’s designed for PHP 8.2+, so ensure your Laravel version aligns with that requirement. For deeper Laravel integration (e.g., Ignition), use `spatie/laravel-flare`.
- Can I use this package in non-Laravel PHP applications like Symfony or custom CLI scripts?
- Yes, this package is explicitly designed for non-Laravel PHP apps. It works seamlessly with Symfony, Lumen, or standalone PHP scripts. The Laravel-specific package (`spatie/laravel-flare`) is only needed for Ignition or framework-tailored features.
- How do I configure the API key and send errors to Flare?
- Set your Flare API key via environment variables (`FLARE_API_KEY`) or directly in the client configuration. Use `Flare::report($exception)` to send exceptions or `Flare::error($message, $level)` for custom errors. The package auto-detects stack traces and request context.
- Does this package support filtering errors (e.g., ignore E_NOTICE or specific exceptions)?
- Yes, you can configure error levels via `Flare::setReportErrorLevels()` to filter out specific errors (e.g., `E_NOTICE`). You can also override default behavior for exceptions or custom attributes using the client’s configuration methods.
- How does this package handle sensitive data like passwords or API keys in error reports?
- The package automatically censors sensitive data in request bodies, cookies, and sessions using wildcard patterns (e.g., `password`, `api_key`). You can extend this with custom censoring rules via `Flare::setCensorCallback()` for application-specific fields.
- Can I self-host Flare and use a custom API endpoint with this package?
- Yes, the package supports custom API endpoints. Set the `FLARE_API_URL` environment variable or configure it directly in the client to point to your self-hosted Flare instance. This is useful for private or air-gapped deployments.
- How does performance impact compare to alternatives like Sentry or Rollbar?
- This package is optimized for low overhead, with batched requests and minimal memory usage. Unlike heavier alternatives like Sentry, it avoids global state and focuses solely on error reporting. Benchmarks show negligible latency, making it ideal for production environments.
- What testing strategies should I use for error reporting in CI/CD?
- Mock the Flare API in tests using HTTP clients like Guzzle or Pest’s mocking tools. Test edge cases like network failures, censoring rules, and custom attributes. The package includes built-in test coverage for core functionality, but validate your specific use case.
- Are there alternatives to spatie/flare-client-php for Laravel error monitoring?
- For Laravel, consider `spatie/laravel-flare` for deeper integration (e.g., Ignition support). Other alternatives include Sentry (more feature-rich but heavier) or Rollbar (enterprise-focused). This package is lighter and framework-agnostic, ideal if you need simplicity or non-Laravel support.