Skip to content

Commit 44fdbff

Browse files
authored
Merge pull request #1 from abrouter/add-feature-flags-usage-example
Add feature flags usage example
2 parents 5e3b272 + 4fd93d2 commit 44fdbff

File tree

10 files changed

+106
-24
lines changed

10 files changed

+106
-24
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ EXPOSE 80
2929

3030
VOLUME ["/app/storage/logs", "/var/log/nginx", "/var/log/php"]
3131

32-
WORKDIR /app
32+
WORKDIR /app
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
namespace App\Http\Controllers;
5+
6+
use Abrouter\Client\Client;
7+
8+
class ExampleFeatureFlagsController
9+
{
10+
public function __invoke(Client $client)
11+
{
12+
$enabledButtonFeatureFlag = $client->featureFlags()->run('enabled_button_feature_flag');
13+
$disabledButtonFeatureFlag = $client->featureFlags()->run('disabled_button_feature_flag');
14+
15+
return view('featureFlags', [
16+
'enabledButtonFeatureFlag' => $enabledButtonFeatureFlag,
17+
'disabledButtonFeatureFlag' => $disabledButtonFeatureFlag,
18+
]);
19+
}
20+
}

composer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"license": "MIT",
77
"require": {
88
"php": "^8.0",
9-
"abrouter/abrouter-laravel-bridge": "^0.6",
10-
"abrouter/abrouter-php-client": "0.4.0",
9+
"abrouter/abrouter-laravel-bridge": "^0.11",
1110
"fruitcake/laravel-cors": "^2.0",
1211
"guzzlehttp/guzzle": "^7.0.1",
1312
"laravel/framework": "^8.54",

composer.lock

+21-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker/provision/after-build.sh

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ rm -rf \
2222
/usr/lib/php/20131226 \
2323
/entypoint.sh
2424

25+
mkdir -p /var/cache/nginx/
26+
2527
find /var/log -type f | while read f; do
2628
echo -ne '' > ${f} 2&>1 > /dev/null || true;
2729
done

public/imgs/controller.png

85.9 KB
Loading

public/imgs/template.png

50.3 KB
Loading

resources/views/button.blade.php

+3
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313

1414
<button style="background: {{$color}}; padding: 10px; border-radius: 3px; margin-left: 20%;">Hello</button>
1515

16+
<br/>
17+
<a href="/feature-flags">Check the feature flags <example></example></a>
18+
1619
</body>
1720
</html>
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Laravel Test page</title>
6+
</head>
7+
<body>
8+
9+
<div>Hello. It's a ABRouter feature flags example. </div>
10+
<br/>
11+
@if ($enabledButtonFeatureFlag)
12+
<button>This button is showing</button>
13+
@endif
14+
<br/>
15+
<br/>
16+
17+
And the next button is not showing.
18+
<br/>
19+
<br/>
20+
21+
22+
@if ($disabledButtonFeatureFlag)
23+
<button>This button is not showing</button>
24+
@endif
25+
Let's inspect the code to understand how it works:
26+
27+
<br/>
28+
<br/>
29+
<br/>
30+
Controller:
31+
<br/>
32+
33+
<img src="/imgs/controller.png" width="50%"/>
34+
35+
<br/>
36+
<br/>
37+
<br/>
38+
And the part of template:
39+
<br/>
40+
41+
<img src="/imgs/template.png" width="50%"/>
42+
43+
<br/>
44+
<br/>
45+
<br/>
46+
<div style="width: auto; margin-left:47%;"><a href="/">Back to the main page</a>
47+
</div>
48+
<br/>
49+
<br/>
50+
<br/>
51+
52+
53+
54+
</body>
55+
</html>

routes/web.php

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use App\Http\Controllers\ExampleController;
4+
use App\Http\Controllers\ExampleFeatureFlagsController;
45
use Illuminate\Support\Facades\Route;
56

67
/*
@@ -15,3 +16,5 @@
1516
*/
1617

1718
Route::get('/', ExampleController::class);
19+
Route::get('/feature-flags', ExampleFeatureFlagsController::class);
20+

0 commit comments

Comments
 (0)