- How do I install mbvienasbaitas/strapi-laravel-client in a Laravel app?
- Install it with Composer using composer require mbvienasbaitas/strapi-laravel-client. The service provider is auto-discovered, then you publish the config file and set your Strapi base URL, API version, auth mode and cache settings. After that you create one model class per Strapi content type and query it with the fluent builder. Expect an afternoon of work to get a first content type rendering.
- Which Laravel and PHP versions does this Strapi client support?
- The package targets Laravel 9 through 12 on PHP 8.1 and above, which matches current Laravel support windows. It plugs into the standard Laravel HTTP client, cache and service provider stack, so no extra infrastructure is needed. Always confirm the constraints in the package composer.json before upgrading Laravel, since a small package like this can lag on new major versions.
- How do I filter, sort, paginate and populate relations with the fluent builder?
- Each content type gets a model class that exposes Eloquent-style methods: where for filters, sort for ordering, paginate for page and page size, populate for relations, and fields to limit the payload. Calls chain fluently and resolve to a single HTTP request against the Strapi REST API. Complex Strapi filter syntax, such as deep relation filtering or localisation, may still require passing raw filter arrays that leak upstream query semantics into your code.
- Does this package work with both Strapi v4 and Strapi v5?
- The config includes a version switch so the client can adapt to different Strapi response envelopes, but v4 to v5 changed the shape of responses significantly (nested data.attributes versus flattened resources). Treat version support as something to verify rather than assume: pin the Strapi version in config and run contract tests against a fixed Strapi Docker image in CI. This is the most likely source of a breaking change in a future release.
- How does caching work, and do I need Redis or Memcached?
- Caching is layered on Laravel's HTTP client and cache repository, and the fluent builder exposes a cache method so you can cache per query. If you want cache tags for granular invalidation, you need a tag-capable store such as Redis or Memcached; file, database and array drivers do not support tags. There is no built-in stale-while-revalidate or stale-cache fallback, so plan a TTL strategy that keeps you inside Strapi's rate limits and latency budget.
- How do I authenticate the client against Strapi?
- The published config supports both API token authentication and credential-based JWT authentication, so you can use a read-only token for content delivery and full credentials only where needed. Keep tokens in environment variables and out of version control, and scope the API token to read permissions on the content types you actually query. Because the client is read-mostly, a read-only token is usually enough.
- Can I use this package to create, update or upload media to Strapi?
- The package is a read-mostly data-access layer: querying, filtering, pagination, sorting, population and caching of content. Write paths such as Draft and Publish workflows, preview tokens and media uploads are not part of the abstraction, so you would fall back to raw Laravel HTTP client calls for those. If your application is write-heavy, this client is not the right boundary.
- How should I test a Laravel app that uses this Strapi client?
- Use Laravel's Http::fake to stub Strapi responses in unit and feature tests, and store golden response fixtures per content type so schema drift shows up as a failing test instead of a silent null. Add a small contract test suite that runs against a pinned Strapi image in CI to catch envelope changes between versions. Because attributes are magic and untyped, static analysis will not catch field renames for you, so fixture-based smoke tests are the practical safety net.
- What happens if Strapi is down or rate limits my app with a 429?
- There is no built-in circuit breaker, retry policy or stale-cache fallback, so a Strapi outage or a burst of 429 responses propagates straight to your users. Mitigate with cache-first reads, a retry and backoff wrapper around the client, and a fallback render path for critical pages. Also monitor error rates and p95 latency, since the dominant runtime risk is the extra HTTP hop on every uncached request.
- Is this package production-ready and maintained, and what are the alternatives?
- It is MIT licensed and technically sound for what it does, but with roughly ten stars and a single maintainer the main risk is supply chain and version drift rather than code quality. Pin the version, keep fork-and-patch capability, and hide the package behind a ContentRepository interface so it can be swapped for a small Guzzle or Laravel HTTP client wrapper in under a week. If you only need a few read endpoints, a hand-rolled client is a legitimate alternative; if you need a full integration platform with typed DTOs, webhooks or sync, this package is not it.