File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 *
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments