Skip to content

Commit 55aaebe

Browse files
committed
initial commit
0 parents  commit 55aaebe

6 files changed

Lines changed: 173 additions & 0 deletions

File tree

‎.editorconfig‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# EditorConfig helps maintain consistent coding styles between editors
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_style = space
9+
indent_size = 2
10+
trim_trailing_whitespace = true
11+
12+
[*.php]
13+
insert_final_newline = true
14+
indent_size = 4

‎.gitignore‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Dependency directories
2+
vendor/
3+
4+
# Composer files
5+
# composer.lock
6+
7+
# PHPUnit
8+
.phpunit.result.cache
9+
10+
# IDEs and editors
11+
/.idea/
12+
/.vscode/
13+
/*.sublime-project
14+
/*.sublime-workspace
15+
16+
# OS generated files
17+
.DS_Store
18+
Thumbs.db
19+
20+
# Logs and caches
21+
*.log
22+
cache/
23+
.phpunit*

‎README.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# featurevisor-example-php
2+
3+
Example PHP application using Featurevisor PHP SDK: https://github.com/featurevisor/featurevisor-php
4+
5+
Learn more about Featurevisor: https://featurevisor.com
6+
7+
## Installation
8+
9+
Clone the repository, and run this with Composer:
10+
11+
```
12+
$ composer install
13+
```
14+
15+
## Usage
16+
17+
```
18+
$ php src/index.php
19+
```
20+
21+
## Featurevisor project
22+
23+
Uses this Featurevisor project to fetch the configuration from: https://github.com/featurevisor/featurevisor-example-cloudflare

‎composer.json‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "featurevisor/featurevisor-example-php",
3+
"description": "Example PHP app using Featurevisor SDK",
4+
"type": "project",
5+
"license": "MIT",
6+
"require": {
7+
"featurevisor/featurevisor-php": "^0.0.3"
8+
}
9+
}

‎composer.lock‎

Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/index.php‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
use function Featurevisor\createInstance;
6+
7+
// fetch datafile
8+
$DATAFILE_URL = "https://featurevisor-example-cloudflare.pages.dev/production/featurevisor-tag-all.json";
9+
$datafileContent = json_decode(file_get_contents($DATAFILE_URL), true);
10+
11+
// create instance
12+
$f = createInstance([
13+
"datafile" => $datafileContent,
14+
]);
15+
16+
// set context
17+
$f->setContext([
18+
"userId" => "12345",
19+
"deviceId" => "device-23456",
20+
"country" => "nl",
21+
]);
22+
23+
// evaluate values
24+
if ($f->isEnabled("my_feature")) {
25+
echo "Feature is enabled!";
26+
} else {
27+
echo "Feature is disabled.";
28+
}

0 commit comments

Comments
 (0)