All questions

Can I use the PHP SDK on a plain PHP app with no framework?

Asked by devon_82 on

Ddevon_82

Legacy app here. Plain PHP, no Laravel or Symfony anywhere and no plan to add one. I want to render one personalized slot server-side.

Every example points at a framework package. Does the core SDK work on its own and how do I fetch a slot safely without something blowing up the page.

Was this helpful?

2 answers

Mmkaminski

Yes, the core PHP SDK works standalone. The Laravel, Symfony, and Drupal packages are convenience layers on top of it, so on a plain app you just use the core one directly, no framework required.

The thing to get right is the fallback. Fetch the slot content server-side and pass a fallback so a failed request returns the default instead of throwing. Content resolves server-side, so there is no client flicker either way, the HTML goes out already personalized. The Laravel server-side SDK thread shows the same fetch-with-fallback shape if you want a fuller example, the core call is the same minus the framework glue.

Was this helpful?
SOSam Okafor

One thing to pin down before you ship: the slot version. Use a versioned slot ID like home-hero@2. If you omit the version you get latest, which means a later publish that changes the slot schema can silently drift out from under your code and break the page.

Pin it explicitly. Then a new version only reaches you when you bump the number, not the moment someone hits publish in the dashboard.

Was this helpful?
Ddevon_82

Good call on the pinned version, was about to leave it off. Core package it is

Still have questions?