- What is the primary use case for the answear/luigis-box-bundle in Laravel?
- This bundle integrates Luigi's Box for content updates, search functionality, and caching in Laravel applications. It’s ideal for real-time product data syncs, API-driven content management, or dynamic search results with low-latency responses. The bundle handles content updates via Luigi’s API while abstracting configuration complexity.
- How do I install and configure the bundle for Laravel?
- Run `composer require answear/luigis-box-bundle` to install. Configure it in `config/packages/answear_luigis_box.yaml` with your Luigi’s Box `publicKey` and `privateKey`. Define timeouts (e.g., `connectionTimeout`, `searchTimeout`) and cache TTL (up to 300 seconds). Omit `default_config` if using a single configuration.
- Does this bundle support multiple Luigi’s Box configurations in one Laravel app?
- Yes. Define multiple configs in the YAML file and set a `default_config`. Switch configurations dynamically via `$configProvider->setConfig('config_name')`. This is useful for multi-tenant apps or environments requiring different Luigi’s Box endpoints.
- What Laravel versions are compatible with this bundle?
- The bundle is designed for Laravel 8.x, 9.x, and 10.x (LTS versions). Check the package’s `composer.json` for exact version constraints. Symfony compatibility is maintained, so it works seamlessly in Laravel’s ecosystem. No PHP extensions are required beyond native UUID support.
- How do I handle custom headers for Luigi’s Box search requests?
- Use the `ConfigProvider` to set headers dynamically: `$configProvider->setHeader('X-Custom-Header', 'value')`. Reset all headers with `$configProvider->resetHeaders()`. This is useful for adding authentication tokens, API keys, or custom metadata to search requests.
- Can I use this bundle for real-time product data updates in e-commerce?
- Absolutely. The bundle supports Luigi’s Box content updates via `ContentUpdate` and `ContentUpdateCollection` objects. Pass product titles, URLs, and metadata to sync inventory, pricing, or descriptions in real-time. Ideal for headless commerce or API-driven storefronts.
- What happens if Luigi’s Box API timeouts occur during a search?
- Configure `searchTimeout` (default: 6.0 seconds) in your YAML or via `ConfigDTO`. If the timeout is exceeded, the request fails gracefully. Use `searchCacheTtl` to cache results (up to 300 seconds) and reduce API calls. Monitor errors via Laravel’s logging or custom middleware.
- Are there alternatives to this bundle for Luigi’s Box integration in Laravel?
- For direct Luigi’s Box integration, alternatives include raw HTTP clients (e.g., Guzzle) or custom services wrapping their API. However, this bundle provides Laravel-specific abstractions (e.g., config management, DTOs for content updates) and Symfony compatibility, reducing boilerplate. It’s the most streamlined option for Laravel apps.
- How do I test the bundle’s functionality in a Laravel app?
- Use Laravel’s HTTP tests to verify content updates and search responses. Mock Luigi’s Box API calls with factories or `Http::fake()`. Test edge cases like timeouts, invalid keys, or malformed content updates. The bundle’s `RequestInterface` makes it easy to swap implementations for testing.
- What are the production concerns when deploying this bundle?
- Monitor API response times and cache hit ratios. Validate `publicKey`/`privateKey` security in production. Use feature flags for gradual rollouts if needed. Ensure your Laravel app’s timeout settings (e.g., `queue.worker.timeout`) accommodate Luigi’s Box request durations. Log errors for debugging without exposing sensitive keys.