> For the complete documentation index, see [llms.txt](https://docs.abtasty.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.abtasty.com/server-side/sdks/php/php-migration-to-4x.md).

# Migration to v4.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](https://github.com/flagship-io/flagship-ts-sdk/releases)

## Visitor Creation

In version 4.X, the [VisitorBuild](/server-side/sdks/php/php-reference.md#visitorbuilder-class) api has been updated to be more descriptive.

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

{% tabs %}
{% tab title="Now" %}

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

{% endtab %}

{% tab title="Before" %}

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

{% endtab %}
{% endtabs %}

## Flagship configuration

In version 4.X, the `setStatusChangedCallback`setter of [FlagshipConfig](/server-side/sdks/php/php-reference.md#flagshipconfig-class) has been replaced with [`setOnSdkStatusChanged`](/server-side/sdks/php/php-reference.md#setonsdkstatuschanged-accessor).

## Flagship SDK Status

The `FlagshipStatus` class has been superseded by [`FSSdkStatus`](/server-side/sdks/php/php-reference.md#getstatus-method).

The table below matches the `FlagshipStatus` enum keys from version 3.X to the corresponding [`FSSdkStatus`](/server-side/sdks/php/php-reference.md#getstatus-method) keys in version 4.X.

| V4.X                  | V3.X             |
| --------------------- | ---------------- |
| SDK\_NOT\_INITIALIZED | NOT\_READY       |
| SDK\_NOT\_INITIALIZED | NOT\_INITIALIZED |
| SDK\_INITIALIZING     | STARTING         |
| SDK\_INITIALIZING     | POLLING          |
| SDK\_PANIC            | READY\_PANIC\_ON |
| SDK\_INITIALIZED      | READY            |

\\

## `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](/server-side/sdks/php/php-reference.md#getflag-method) method of visitor instance. Instead, it is now set using the [getValue](/server-side/sdks/php/php-reference.md#getvalue-method) of [flag](/server-side/sdks/php/php-reference.md#getflag-method) instance.

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

{% tabs %}
{% tab title="Now" %}

```php

...

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

{% endtab %}

{% tab title="Before" %}

```php

...

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

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.abtasty.com/server-side/sdks/php/php-migration-to-4x.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
