boxalino/boxalino-client-sdk-php
PHP client SDK for integrating Boxalino's search, navigation, and personalization services into ecommerce sites. It provides API wrappers for querying product catalogs and retrieving personalized search results, with Composer-based installation for Laravel or standalone PHP projects.
This is the first release containing the CPO Narratives integration, so start by confirming the package name and install command in its README, then require it with Composer and publish its config:
composer require <vendor>/<package>
php artisan vendor:publish --provider="<Vendor>\CpoNarratives\CpoNarrativesServiceProvider"
Look first at:
A typical first use case is rendering a personalized narrative block on the home page or product page. The flow is usually: resolve a visitor/customer context, request one or more narratives for that context, then render the returned content in Blade. The exact API will be package-specific, but expect something shaped like:
use Vendor\CpoNarratives\Facades\Narratives;
$narrative = Narratives::context([
'customer_id' => auth()->id(),
'page_type' => 'home',
'locale' => app()->getLocale(),
])->get('homepage_hero');
{!! $narrative?->render() !!}
Before wiring it into production views, verify credentials against the Boxalino sandbox or a staging account and confirm that the API returns a narrative for a known test context.
Context resolution belongs in one place. Rather than passing customer/session/page data at every call site, build a small context resolver (a service, middleware, or request macro) that assembles the Boxalino context once per request. Controllers and Blade views should consume that context, not reconstruct it.
Wrap the client in your own gateway. Even a thin application-level wrapper around the package facade pays off: it gives you a single place for fallback behavior, logging, cache keys, and later API changes. This is especially important for a v1.5 feature whose API surface may still move.
Render narratives through a Blade component. Encapsulate retrieval and rendering in a component such as <x-boxalino-narrative slot="homepage_hero" />. That keeps views clean, makes fallback content explicit, and gives you one place to handle empty responses.
Cache per context, not globally. Narrative responses are personalized, so the cache key must include the relevant context dimensions (customer/visitor ID, locale, page type, slot). Use the package's cache settings if present, but verify the key strategy. If the package caches internally, confirm it does not collapse different visitors into one entry.
Fallback content is part of the pattern. Treat Boxalino as an enhancement, not a hard dependency. Every narrative slot should have a sensible default so a slow or failed API call does not break the page.
<x-boxalino-narrative slot="homepage_hero">
<x-default-hero />
</x-boxalino-narrative>
Test with a fake or stub client. Bind a fake implementation of the package client in tests so you can assert that the correct context and slot are requested without hitting the network. If the package does not provide a fake, wrap it behind an interface you can swap.
Use it for multiple slots, not one-off calls. The value of CPO Narratives comes from personalizing several placements (hero, recommendations, category copy, product upsell). Define your slots centrally in config and iterate over them, rather than scattering ad hoc API calls through controllers.
Integration tip: resolve context early. If the context depends on authentication or a visitor cookie, resolve it in middleware and store it on the request. This avoids ordering problems when narratives are rendered in layout partials, view composers, or early Blade sections.
composer.json, read the changelog before upgrading, and expect the API or config keys to evolve in subsequent releases.php artisan config:cache after config changes. As with any Laravel package, config values read at boot time will be stale until the cache is rebuilt. This catches people when rotating API keys.How can I help you explore Laravel packages today?