Skip to content
Nav

Laravel SDK

composer require langsys/langsys-php-laravel
Packagist version Monthly downloads License PHP 8.1+ Laravel 10 / 11 / 12

Integrate the Langsys Translation Manager into a Laravel application — Blade, Livewire, Alpine’s server-rendered content, and Inertia SSR seeding for the JS SDKs.

This is the reference for langsys/langsys-php-laravel. For a walkthrough with a demo app, see the Laravel Learning Center page.

  • PHP 8.1+, Laravel 10, 11, or 12
  • ext-intl (required — ICU plural rules and locale-aware number/date formatting). Note that the official php:8.x-fpm Docker images do not bundle it; add docker-php-ext-install intl.

langsys/langsys-php-laravel is a Laravel wrapper over the dependency-free langsys/langsys-php — which owns the HTTP client, phrase lookup, placeholder interpolation, token discovery/queueing, and catalog caching. This package adds only the Laravel-native concerns:

  • A service provider that builds the SDK Client from config/langsys.php and routes catalog caching through Laravel’s cache (any store — redis, memcached, file, array)
  • A t() helper and @t Blade directive exposing the SDK’s {name} interpolation and ICU pluralization to Blade — the same phrase syntax as the Langsys JS SDKs, so one catalog serves your whole stack
  • A DetectLocale middleware resolving the request locale (query → cookie → session → Accept-Language)
  • A FlushPendingRegistrations terminable middleware (plus an Octane listener) that sends newly discovered phrases to Langsys after the response
  • An opt-in TranslateResponse middleware that translates whole rendered HTML responses, for projects that want coverage without hand-tagging
  • An InertiaSsrProps helper that seeds the JS SDKs’ initialTranslations for SSR handoff
Feedback