vwo / vwo-php-sdk
VWO server side sdk
Installs: 101 547
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 18
Forks: 9
Open Issues: 1
Requires
- justinrainbow/json-schema: ^5.2
- monolog/monolog: ^1.0 || ^2.0
- predis/predis: ^2.2
- ramsey/uuid: ^3.8 || ^4.0
- vwo/vwo-sdk-log-messages: >=0.10.0
Requires (Dev)
- overtrue/phplint: ^1.2
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^4.0
- squizlabs/php_codesniffer: 3.*
- dev-master
- v1.69.0
- v1.68.0
- v1.66.0
- v1.65.0
- v1.64.0
- v1.62.0
- v1.60.0
- v1.58.0
- v1.55.0
- v1.50.0
- v1.46.0
- v1.42.0
- v1.41.0
- v1.37.0
- v1.36.2
- v1.36.1
- v1.36.0
- v1.35.0
- v1.32.3
- v1.32.0
- v1.31.0
- v1.30.0
- v1.28.0
- v1.25.0
- v1.24.0
- v1.23.2
- v1.23.1
- v1.23.0
- v1.22.0
- v1.20.0
- v1.19.0
- v1.18.0
- v1.17.0
- v1.15.0
- v1.14.0
- v1.13.1
- v1.13.0
- v1.12.0
- v1.11.1
- v1.11.0
- v1.10.0
- v1.8.0
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.1
- v1.6.0
- v1.5.2
- v1.5.1
- v1.5.0
- 1.3.0
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-RemseyDependency
- dev-feat-operators
- dev-test-dev
- dev-update-uuid
- dev-github-action-slack-notification
- dev-github-action
- dev-feature-rollout-fix
- dev-monolog-2
This package is auto-updated.
Last update: 2024-11-15 13:14:26 UTC
README
This open source library provides you server-side testing capabilities.
Requirements
PHP >= 5.6
Installation
Install the latest version with
composer require vwo/vwo-php-sdk
Basic Usage
Use the below code for inital setup.
<?php require_once('vendor/autoload.php'); require_once('userStorage.php'); // Optional :if you are using UserStorage service feature require_once('customLogger.php');// Optional :if you are using custom logging feature use vwo\VWO; $accountId = REPLACE_WITH_VWO_ACCOUNT_ID; // eg: 123456 $sdkKey = 'REPLACE_WITH_TOKEN'; // eg: can be found in VWO app - FullStack project $campaignKey = 'CAMPAIGN_UNIQUE_TEST_KEY'; $userId = 'USER_ID'; $goalIdentifier = 'REPLACE_WITH_CAMPAIGN_GOAL_IDENTIFIER'; // to fetch the settings i.e campaigns, variations and goals $settingsFile = VWO::getSettingsFile($accountId, $sdkKey); $sdkConfig = [ 'settingsFile' => $settingsFile, 'isDevelopmentMode' => 0, // optional: 1 to enable the dev mode 'logging' => new CustomLogger(), // optional 'userStorageService' => new userStorageService() // optional ]; $vwoClient = new VWO($sdkConfig); // to get the variation name along with add a visitor hit to vwo app stats $variation = $vwoClient->activate($campaignKey, $userId, $options); // Or, to get the variation name $variation = $vwoClient->getVariationName($campaignKey, $userId, $options); // add code here to use variation //... /** *send the track api hit to the vwo app stats to increase conversions * $revenue is optional send in case if there is any revenue inside $options */ $vwoClient->track($campaignKey, $userId, $goalIdentifier, $options);
Code for implementing User Storage Service
<?php require_once('vendor/autoload.php'); use vwo\Utils\UserStorageInterface; Class UserStorage implements UserStorageInterface{ /** * @param $userId * @param $campaignKey * * @return array */ public function get($userId, $campaignKey) { // search in DB/Storage system $variation = $db->fetch($userId, $campaignKey); // replace with your implementation return[ 'userId' => $userId, 'campaignKey' => $campaignKey, 'variationName' => $variation ]; } /** * @param $campaignUserMapping * @return bool - could be changed */ public function set($campaignUserMapping) { // S...code to store in DB/storage system return True; } }
Code for implementing Custom Logger
<?php require_once('vendor/autoload.php'); use vwo\Logger\LoggerInterface; /** * Class CustomLogger */ Class CustomLogger implements LoggerInterface{ /** * @param $message * @param $level * * @return */ public function log($message, $level){ // use $level and log $message to either print or store them for later use } }
Documentation
Refer Official VWO Documentation
Third-party Resources and Credits
Refer third-party-attributions.txt
Changelog
Refer CHANGELOG.md
Development and Test Cases
- Set development environment
composer run-script start
- Run test cases
composer run-script test
- Run linter
composer run-script test
- Run code beautifier
composer run-script phpcbf
License
Copyright 2019-2022 Wingify Software Pvt. Ltd.