- How do I install the apisearch-io/php-client in a Laravel project?
- Use Composer to install the package with `composer require apisearch-io/php-client`. No additional Laravel-specific setup is required, but you’ll need to configure the API key and endpoint in your application. The client works seamlessly with Laravel’s HTTP client or Guzzle under the hood.
- Does this package support Laravel’s Scout for search functionality?
- No, this package is not a Scout engine. It’s a standalone client for ApiSearch.io’s API, so you’ll need to manually integrate it into your Laravel application. However, you can wrap it in a service class to mimic Scout’s interface if desired.
- What Laravel versions are compatible with apisearch-io/php-client?
- The package is designed for modern Laravel versions (8.x and 9.x) and PHP 8.0+. It leverages Laravel’s HTTP client and dependency injection, so it integrates cleanly with newer Laravel features. Older versions may require adjustments for compatibility.
- Can I use this client for bulk indexing in Laravel?
- Yes, the client supports bulk indexing via ApiSearch’s API. For Laravel, you can offload bulk operations to queues using Laravel’s queue system (e.g., `ApisearchBulkIndexJob`). This ensures smooth performance even with large datasets.
- How do I handle authentication with ApiSearch in Laravel?
- Authentication is handled via the ApiSearch API key, which you configure when initializing the client. You can store the key in Laravel’s `.env` file and pass it to the client constructor. The package abstracts the HTTP auth headers, so no manual token management is needed.
- Is there built-in support for faceted search or filters in this client?
- Yes, the client provides methods to execute search queries with filters, facets, and sorting directly through ApiSearch’s API. You can pass these parameters as an associative array to the search method, and the client will format them correctly for the API.
- What happens if ApiSearch’s API is down or unresponsive in production?
- The package doesn’t include built-in fallback logic, but you can implement retries or caching in Laravel. For example, use Laravel’s `retry` helper or cache frequent queries to degrade gracefully. Consider monitoring ApiSearch’s uptime and setting alerts for outages.
- Can I integrate ApiSearch webhooks with Laravel?
- Yes, ApiSearch supports webhooks for real-time updates. In Laravel, you can use packages like `spatie/laravel-webhooks` or Laravel’s built-in `route:webhook` to handle incoming webhook events, such as index updates or search triggers.
- Are there alternatives to this package for Laravel search?
- If you’re looking for alternatives, consider Laravel Scout (for self-hosted engines like Algolia or Meilisearch) or dedicated PHP clients for other search services like Algolia, Typesense, or Elasticsearch. Each has tradeoffs in cost, control, and ease of integration.
- How do I test my Laravel application’s integration with ApiSearch?
- Use Laravel’s HTTP testing helpers to mock ApiSearch’s API responses. For example, stub the HTTP client to return test data during unit tests. For end-to-end testing, use Laravel’s `Http::fake()` to simulate API calls and verify your search logic without hitting the real service.