apisearch-io/php-client
Official PHP client for the ApiSearch.io search-as-a-service platform. Provides a simple API to index documents, manage indices and queries, and retrieve fast, relevant search results from your PHP or Laravel applications.
Http::macro), Promises, and service containers. Can be injected via dependency injection.Apisearch::search() shortcut). Requires manual setup.queue:work) could offload heavy indexing tasks.route:webhook or spatie/laravel-webhooks could handle event-driven updates.| Risk Area | Mitigation Strategy |
|---|---|
| Vendor Lock-in | Evaluate Apisearch’s pricing, SLAs, and migration path to alternatives (e.g., Meilisearch, Typesense). |
| Latency | Test API response times under load. Cache frequent queries (e.g., Laravel’s cache()). |
| Cost at Scale | Monitor indexing/query volume. Apisearch’s pricing may scale with usage (e.g., $/GB indexed or $/query). |
| Data Privacy | Ensure compliance with GDPR/CCPA if handling PII. Apisearch’s data residency options must align with regulations. |
| Deprecation Risk | Package is archived (no recent commits). Fork or maintain a local copy if critical. |
| Feature Gaps | Compare Apisearch’s capabilities (e.g., synonyms, typos tolerance) vs. self-hosted tools. |
Http facade or Guzzle for direct API calls (package wraps these).ApisearchService) injected into controllers/repositories.ModelCreated → index in Apisearch).ApisearchBulkIndexJob).php artisan apisearch:sync) for periodic syncs.Cache::remember('search_results_$query', now()->addHours(1), fn() => Apisearch::search($query))).Cache::tags() for invalidation when data changes.Sentry or Laravel Debugbar.guzzlehttp/guzzle)..env to configure Apisearch API keys, endpoints, etc.
APISEARCH_API_KEY=your_key
APISEARCH_ENDPOINT=https://api.apisearch.io
composer require apisearch-io/php-client).// app/Console/Commands/IndexApisearch.php
use Apisearch\Client;
use App\Models\Product;
public function handle() {
$client = new Client(config('apisearch.key'));
$products = Product::all()->toArray();
$client->index('products', $products);
}
// app/Services/ApisearchService.php
public function search(string $query, int $limit = 10) {
return $client->search('products', $query, ['limit' => $limit]);
}
saved, deleted) and update Apisearch:
// app/Models/Product.php
protected static function booted() {
static::saved(fn ($product) => ApisearchService::index($product));
static::deleted(fn ($product) => ApisearchService::delete($product->id));
}
composer.json to avoid breaking changes.try {
$result = $client->search(...);
} catch (\Throwable $e) {
\Log::error("Apisearch failed", ['error' => $e->getMessage(), 'query' => $query]);
throw $e;
}
spatie/fractal) to fail gracefully during outages.How can I help you explore Laravel packages today?