- Can I use this package in a Laravel project without Symfony components?
- Yes, but you’ll need to replace Symfony dependencies like `HttpClient` and `Messenger` with Laravel equivalents. Use Laravel’s `HttpClient` or Guzzle for API calls and Laravel Queues (`bus:dispatch`) instead of Symfony Messenger. The core Zabbix API logic remains compatible.
- What Laravel versions does this package support?
- The package requires PHP 8.3+ and works with Laravel 10.x or 11.x. It leverages modern PHP features like enums and strict typing, which align with Laravel’s recent PHP 8.2+ adoption. No Laravel-specific version is enforced, but Symfony components may require Laravel 9+.
- How do I configure persistent token caching in Laravel?
- Use the `ZABBIX_AUTH_TTL` environment variable to set token cache duration (e.g., `3600` for 1 hour). The package defaults to Symfony’s cache, but you can extend it to use Laravel’s `Cache` facade by overriding the `TokenCacheInterface` binding in your service container.
- Is there a way to mock the Zabbix API for unit testing?
- Yes, the package provides `ZabbixServiceInterface`, which you can mock in tests. Use Laravel’s `Mockery` or PHPUnit’s mock builder to simulate API responses. For integration tests, consider using a test Zabbix instance or a mock HTTP client like `HttpClient::fake()`.
- How do I handle asynchronous metric pushes in Laravel?
- Replace Symfony Messenger with Laravel Queues by dispatching messages via `Bus::dispatch()`. For example, use `PushMetricMessage` with Laravel’s `dispatch()` method. Ensure your queue worker processes messages to push metrics to Zabbix asynchronously.
- What if my Zabbix API version isn’t fully supported?
- The package covers most Zabbix API endpoints (hosts, items, triggers, etc.), but version mismatches may require updates. Check the [GitHub issues](https://github.com/bytes-commerce/zabbix-api/issues) for known limitations. Extend the `ZabbixServiceInterface` or override specific actions if needed.
- Can I use this package for production monitoring without Symfony?
- Absolutely. Abstract Symfony dependencies behind interfaces (e.g., `HttpClientInterface`) and bind Laravel’s equivalents in your service container. The package’s core functionality—auth, actions, and history retrieval—remains usable. Async features require Laravel Queues instead of Messenger.
- Are there alternatives to this package for Laravel?
- For Laravel-specific solutions, consider `spatie/zabbix-api` (simpler, less type-safe) or `laravel-zabbix/zabbix` (older, PHP 7.x). This package offers stricter typing, async support, and broader API coverage but requires manual Symfony component replacements in vanilla Laravel.
- How do I debug authentication failures or rate limits?
- Enable Laravel’s debug mode and check logs for HTTP errors. The package retries failed auth requests automatically. For rate limits, implement exponential backoff in your custom `HttpClient` wrapper or use Laravel’s `retry()` helper for API calls.
- Does this package support auto-provisioning of Zabbix hosts/items?
- Yes, the package includes auto-setup features like host and item provisioning. Use actions like `Host` or `Item` with their respective DTOs (e.g., `CreateHostDto`) to automate Zabbix configurations. Configure via environment variables or extend the `ZabbixService` for custom logic.