- How do I install Laravel Slower in a Laravel 12.x project?
- Run `composer require halilcosdu/laravel-slower` in your project directory. The package supports Laravel 12.x natively with no additional steps. Ensure PHP 8.2+ is installed, as it’s a requirement for Laravel 12.x compatibility.
- Does Laravel Slower work with Laravel 13.x, and are there any breaking changes?
- Yes, Laravel Slower fully supports Laravel 13.x with no breaking changes in v2.1.0. The package leverages updated dependencies like Orchestra Testbench 11.x and PHPUnit 11+ to ensure seamless integration with Laravel 13’s new features, including improved model events.
- Can I disable AI recommendations to avoid OpenAI API costs?
- Yes, set `ai_recommendation` to `false` in the published config file. This disables AI-powered suggestions entirely, preventing API calls to OpenAI while retaining slow query logging functionality. Useful for production environments where cost control is critical.
- What’s the minimum query execution time threshold for logging slow queries?
- The default threshold is 10,000 milliseconds (10 seconds). Adjust it in the config file under the `threshold` key to match your application’s performance needs. Lower values capture slower queries but may increase log volume.
- How does Laravel Slower handle database connections in multi-environment setups?
- Laravel Slower uses Eloquent’s built-in connection handling, so it respects your `.env` configuration for different environments (e.g., `DB_CONNECTION=mysql`). Ensure your `SLOWER_ENABLED` env variable is set per environment to control logging behavior.
- Are there alternatives to Laravel Slower for Laravel 9.x or older projects?
- Laravel Slower no longer supports Laravel 9.x or older. For legacy projects, consider alternatives like `barryvdh/laravel-debugbar` (for query inspection) or `spatie/laravel-query-logger` (for manual logging). Upgrading to Laravel 10.x first is recommended for full compatibility.
- How can I customize the AI prompt for query recommendations?
- The package allows custom AI prompts via the config file. Modify the `ai_prompt` key to tailor recommendations to your database schema or specific optimization goals. Test changes in a staging environment to validate the output before production use.
- Will Laravel Slower impact production performance during monitoring?
- Minimal impact is expected, as the package only logs queries exceeding the threshold. However, enabling AI recommendations adds latency due to OpenAI API calls. Disable AI in production (`ai_recommendation=false`) or use a staging environment for testing.
- How do I test Laravel Slower in a CI/CD pipeline?
- Use Laravel’s Testbench to simulate slow queries in unit tests. The package includes GitHub Actions workflows for PHPUnit 11+ and Pest, ensuring compatibility. Mock AI responses in tests to avoid OpenAI API costs during CI runs.
- What happens if OpenAI’s API is unavailable or rate-limited?
- The package gracefully falls back to logging slow queries without AI recommendations. Configure a retry mechanism or fallback prompts in the config to handle intermittent API issues. Monitor OpenAI’s status page for outages.