This repository was archived by the owner on Jun 23, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +96
-5
lines changed Expand file tree Collapse file tree 7 files changed +96
-5
lines changed Original file line number Diff line number Diff line change 1
1
/vendor
2
+ /.idea
2
3
3
4
.phpunit.result.cache
4
5
phpunit.xml
Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ Documentation for configuration can be found in [config/unleash.php](https://git
24
24
## Usage
25
25
26
26
``` php
27
-
28
27
use \MikeFrancis\LaravelUnleash\Unleash;
29
28
30
29
$unleash = app(Unleash::class);
@@ -37,9 +36,49 @@ if ($unleash->isFeatureDisabled('myAwesomeFeature')) {
37
36
// Check back later for more features!
38
37
}
39
38
39
+ $feature = $unleash->getFeature('myAwesomeFeature');
40
+
40
41
$allFeatures = $unleash->getFeatures();
41
42
```
42
43
44
+ ### Facades
45
+
46
+ You can use the ` Unleash ` facade:
47
+
48
+ ``` php
49
+ use Unleash;
50
+
51
+ if (Unleash::isFeatureEnabled('myAwesomeFeature')) {
52
+ // Congratulations, you can see this awesome feature!
53
+ }
54
+
55
+ if (Unleash::isFeatureDisabled('myAwesomeFeature')) {
56
+ // Check back later for more features!
57
+ }
58
+
59
+ $feature = Unleash::getFeature('myAwesomeFeature');
60
+
61
+ $allFeatures = Unleash::getFeatures();
62
+ ```
63
+
64
+ or use the generically named ` Feature ` facade:
65
+
66
+ ``` php
67
+ use Feature;
68
+
69
+ if (Feature::enabled('myAwesomeFeature')) {
70
+ // Congratulations, you can see this awesome feature!
71
+ }
72
+
73
+ if (Feature::disabled('myAwesomeFeature')) {
74
+ // Check back later for more features!
75
+ }
76
+
77
+ $feature = Feature::get('myAwesomeFeature');
78
+
79
+ $allFeatures = Feature::all();
80
+ ```
81
+
43
82
### Blade
44
83
45
84
Blade directive for checking if a feature is ** enabled** :
Original file line number Diff line number Diff line change 32
32
"laravel" : {
33
33
"providers" : [
34
34
" MikeFrancis\\ LaravelUnleash\\ ServiceProvider"
35
- ]
35
+ ],
36
+ "aliases" : {
37
+ "Unleash" : " MikeFrancis\\ LaravelUnleash\\ Facades\\ Unleash" ,
38
+ "Feature" : " MikeFrancis\\ LaravelUnleash\\ Facades\\ Feature"
39
+ }
36
40
}
37
41
}
38
42
}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public function __construct(Config $config)
11
11
{
12
12
parent ::__construct (
13
13
[
14
- 'base_uri ' => $ config ->get ('unleash.url ' ),
14
+ 'base_uri ' => $ config ->get ('unleash.url ' ),
15
15
]
16
16
);
17
17
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace MikeFrancis \LaravelUnleash \Facades ;
3
+
4
+ use Illuminate \Support \Facades \Facade ;
5
+
6
+ class Feature extends Facade
7
+ {
8
+ public static function enabled (string $ feature , ...$ args ): bool
9
+ {
10
+ return static ::isFeatureEnabled ($ feature , ...$ args );
11
+ }
12
+
13
+ public static function disabled (string $ feature , ...$ args ): bool
14
+ {
15
+ return static ::isFeatureDisabled ($ feature , ...$ args );
16
+ }
17
+
18
+ public static function all (): array
19
+ {
20
+ return static ::getFeatures ();
21
+ }
22
+
23
+ public static function get (string $ name )
24
+ {
25
+ return static ::getFeature ($ name );
26
+ }
27
+
28
+ protected static function getFacadeAccessor ()
29
+ {
30
+ return 'unleash ' ;
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace MikeFrancis \LaravelUnleash \Facades ;
3
+
4
+ use Illuminate \Support \Facades \Facade ;
5
+
6
+ class Unleash extends Facade
7
+ {
8
+ protected static function getFacadeAccessor ()
9
+ {
10
+ return 'unleash ' ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ class ServiceProvider extends IlluminateServiceProvider
15
15
public function register ()
16
16
{
17
17
$ this ->mergeConfigFrom ($ this ->getConfigPath (), 'unleash ' );
18
+ $ this ->app ->singleton ('unleash ' , function ($ app ) {
19
+ $ client = $ app ->make (Client::class);
20
+ return $ app ->make (Unleash::class, ['client ' => $ client ]);
21
+ });
18
22
}
19
23
20
24
/**
@@ -26,11 +30,10 @@ public function boot()
26
30
{
27
31
$ this ->publishes (
28
32
[
29
- $ this ->getConfigPath () => config_path ('unleash.php ' ),
33
+ $ this ->getConfigPath () => config_path ('unleash.php ' ),
30
34
]
31
35
);
32
36
33
-
34
37
Blade::if (
35
38
'featureEnabled ' ,
36
39
function (string $ feature ) {
You can’t perform that action at this time.
0 commit comments