PHP Feature Flags

Split's PHP SDK provides robust, scalable feature flag management, giving any team the power to safely launch features and target them to users.

Begin your free trial today.

Why use Split for PHP?

Split’s PHP SDK bring free, scalable feature flagging to any app, website or experience built in PHP. Split helps teams control rollouts, and customer experiences, while gathering new data and insight on how their products are being engaged. With Split, teams can:

  • Release features to production but disabled for all users by default
  • Target new features only to internal QA teams
  • Slowly roll out features to a broader audience by percentage, demographic, geography, account type, or any other metric
  • Kill features with a single click to revert back to your safe state

Split works across many different languages, letting developers, PMs and support teams control feature rollout from one unified view—and monitor the success of any new code. Our integrations bring rollout updates into the tools your team is already using, further opening the feature-delivery process up to your entire organization.

Split's PHP Architecture

Because of the share nothing-nature of PHP, the PHP SDK architecture is different from other SDKs. The SDK has three components:

  • The Synchronizer Service is responsible for fetching the data from Split servers it needs to evaluate what treatment to show to a customer. It is a background service that can be run on one machine on a schedule via your scheduling system. We recommend supervisord.
  • The cache component is where the Synchronizer Service stores its fetched data. The SDK comes pre-packaged with a Redis Cache Adapter. It is critical that Redis is configured to never evict.
  • The SDK client is embedded within your PHP app. It is the brains that decides which treatment to show to a customer for a particular split.

Visit our documentation to learn more about Split's PHP architecture considerations.

Getting Started with Split for PHP

Split's PHP SDK is very simple to integrate into your code base and is completely open source. All it really takes to get rolling with Split is initiating the SDK, then splitting your code.

Initiating the SDK

First, import the SDK into your project:

          composer require splitsoftware/split-sdk-php:4.1.0

Setting Up the Synchronizer Service

Once composer is done, the split synchronizer service will be available in your project's vendor/bin. You can start the service via your preferred scheduling system. We recommend starting the synchronizer via supervisord; a daemon that launches other processes and ensures they stay running. Here is an example of how to configure supervisord for the Synchronizer.

A sample of the configuration file will be available under the vendor path. Copy it to a know location.

cp /path/to/your/project/vendor/splitsoftware/split-sdk-php/bin/splitio.dist.ini /opt/splitsoftware/splitio.ini

Run the synchronizer under supervision

Find below a sample file to set up supervisord

command=/usr/bin/env php /path/to/your/project/vendor/bin/splitio --service --config-file="/opt/splitsoftware/splitio.ini"
process_name = SplitIO
numprocs = 1
user = root
stderr_logfile_maxbytes = 1MB
stdout_logfile_maxbytes = 1MB

If you're running Heroku, you can run synchronizer service as a dyno worker by configuring your Profile:

worker: php vendor/bin/splitio --service --config-file="service/splitio.ini"

Instantiate the SDK and Create a New Split Client

Then instantiate the SDK and create a new Split client:


$parameters = ['scheme' => 'tcp',
               'host' => REDIS_HOST,
               'port' => REDIS_PORT,
               'timeout' => 881

$options = ['prefix' => ''];

$sdkConfig = array(
    'log' => array('adapter' => 'syslog', 'level' => 'error'),
    'cache' => array('adapter' => 'predis',
                     'parameters' => $parameters,
                     'options' => $options

$splitFactory = \SplitIO\Sdk::factory('YOUR_API_KEY', $sdkConfig);
$splitClient = $splitFactory->client();


Include the API key for the environment you are setting up the SDK for. The API key is available under your Organization Settings page, under the APIs tab. The API key is of type sdk

Splitting your code.

With the SDK instantiated, it’s now time to start splitting your code base. Find a feature you’d like to split, and wrap it in the split feature flag like so:

$treatment = $splitClient->getTreatment('CUSTOMER_ID','SPLIT_NAME');

if ($treatment === 'on') {
    // insert code here to show on treatment
} elseif ($treatment === 'off') {
    // insert code here to show off treatment
} else {
    // insert your control treatment code here


The Split PHP SDK integrates seamlessly into your code; no other changes or dependencies are needed to get Split up and running.

For more advanced configurations like running multiple evaluations at once, or using attributes in the SDK, take a look at our PHP SDK documentation.

To continue diving into Split, sign up for a free account today, or dig into our Documentation.