- How do I install the Recombee PHP API client in Laravel?
- Install it with composer require recombee/php-api-client, then bind Recombee\RecommApi\Client as a singleton in a Laravel service provider. Pull the database ID, private token, and region from config/services.php and .env so credentials stay out of code. The SDK is Composer-native and PSR-4 autoloaded, so no special Laravel package discovery is required.
- How do I configure the Recombee database ID, token, and region in Laravel?
- Add a recombee entry to config/services.php and read RECOMBEE_DATABASE_ID, RECOMBEE_PRIVATE_TOKEN, and RECOMBEE_REGION from .env. Instantiate the Client with those values in a singleton binding, for example in AppServiceProvider. The client supports regional endpoints such as us-west and ap-se, so set the region that matches your Recombee database.
- What Laravel and PHP versions does recombee/php-api-client support?
- The package is a framework-agnostic Composer SDK, not a Laravel-specific package, so there is no separate Laravel version matrix. Its PHP and dependency constraints are defined in composer.json; install it in any Laravel application that satisfies those constraints. For this repository line, the README shows ^6.3.1 as the Composer requirement, so verify that constraint against your PHP version before upgrading.
- What is the Recombee PHP client used for in a Laravel app?
- Use it when personalization is a feature layer: product carousels, content feeds, users-also-viewed blocks, and search ranking. It sends recommendation, search, and event requests to Recombee's REST API; it is not a self-hosted recommendation engine. In Laravel, wrap it in a service class rather than calling it directly from controllers everywhere.
- How do I send batch requests for large catalog or event imports?
- Build an array of request objects such as Reqs\AddPurchase or Reqs\SetItemValues and send them in a single Reqs\Batch request. This is the right affordance for catalog syncs and backfilled interaction history because it avoids one HTTP round-trip per row. In Laravel, dispatch batch ingestion from queued jobs and use cascadeCreate when users or items may not exist yet.
- How do I handle Recombee API errors and fallbacks in Laravel?
- Catch the common Ex\ApiException parent and branch on subtypes such as ApiTimeoutException and ResponseException where the fallback differs. Define a degraded experience up front, such as popular items, category bestsellers, or an empty state, instead of a generic catch that hides failures. Log the failure with enough context to distinguish timeout, validation, and server errors.
- How do I get follow-up recommendations with RecommendNextItems?
- RecommendItemsToUser returns a recommId alongside the recommended items. Pass that recommId to Reqs\RecommendNextItems with the desired count to fetch the next page for infinite scroll or load-more behavior. Treat the recommId as part of the session or view state, not as a permanent identifier.
- Should I call Recombee synchronously during a Laravel page render?
- Avoid synchronous Recombee calls in page renders unless you have a strict timeout and a defined fallback. Every recommendation is a network round-trip to Recombee's cloud, which is risky for hard latency budgets. Cache recommendations in Redis with a short TTL, precompute high-traffic surfaces, and move event ingestion to Laravel queues.
- How do I test a Laravel integration with the Recombee PHP client?
- Abstract the client behind a RecommendationService interface and swap in a fake or mock in unit tests so tests do not call Recombee. Test request construction, fallback paths, and error handling around the service wrapper. For integration tests, use a non-production Recombee database and clean up test users or items; do not point tests at production credentials.
- Is recombee/php-api-client maintained and what are the alternatives?
- It is a vendor-published official client, MIT-licensed and versioned in lockstep with Recombee's API, which offsets its low public adoption compared with community packages. Alternatives are other official Recombee SDKs, a custom REST wrapper, or a different recommendation vendor if you need on-premise or non-cloud execution. If you adopt it, abstract it behind your own interface to limit vendor lock-in and keep Recombee IDs as external keys.