Migration to 4.X


This guide assists developers in migrating from Flagship 3.X to Flagship 4.X.

The primary changes include:

  • Visitor Creation
  • Flagship configuration
  • Flagship SDK Status

For more details, see the change log

Visitor Creation

In version 4.X, the VisitorBuild api has been updated to be more descriptive.

Below is an example of how consent is used in versions 4.X and 3.X

$visitor = Flagship::newVisitor("visitorId", true)
  ->setContext(["age" => 31, "isVip" => true])
$visitor = Flagship::newVisitor("visitorId", true)
  ->withContext(["age" => 31, "isVip" => true])

Flagship configuration

In version 4.X, the setStatusChangedCallbacksetter of FlagshipConfig has been replaced with setOnSdkStatusChanged.

Flagship SDK Status

The FlagshipStatus class has been superseded by FSSdkStatus.

The table below matches the FlagshipStatus enum keys from version 3.X to the corresponding FSSdkStatus keys in version 4.X.


GetFlag method update

In version 4.X, the approach to setting a flag's default value has been modified. The default value is no longer set using the getFlag method of visitor instance. Instead, it is now set using the getValue of flag instance.

Here's how you can retrieve the default value of a flag in versions 4.X and 3.X:


$flag = $visitor->getFlag("myFlagKey");
$flagValue = $flag->getValue("default-value");


$flag = $visitor->getFlag("myFlagKey", "default-value");
$flagValue = $flag->getValue();