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 11/vendor
2+ /.idea
23
34.phpunit.result.cache
45phpunit.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
2424## Usage
2525
2626``` php
27-
2827use \MikeFrancis\LaravelUnleash\Unleash;
2928
3029$unleash = app(Unleash::class);
@@ -37,9 +36,49 @@ if ($unleash->isFeatureDisabled('myAwesomeFeature')) {
3736 // Check back later for more features!
3837}
3938
39+ $feature = $unleash->getFeature('myAwesomeFeature');
40+
4041$allFeatures = $unleash->getFeatures();
4142```
4243
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+
4382### Blade
4483
4584Blade directive for checking if a feature is ** enabled** :
Original file line number Diff line number Diff line change 3232 "laravel" : {
3333 "providers" : [
3434 " MikeFrancis\\ LaravelUnleash\\ ServiceProvider"
35- ]
35+ ],
36+ "aliases" : {
37+ "Unleash" : " MikeFrancis\\ LaravelUnleash\\ Facades\\ Unleash" ,
38+ "Feature" : " MikeFrancis\\ LaravelUnleash\\ Facades\\ Feature"
39+ }
3640 }
3741 }
3842}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ public function __construct(Config $config)
1111 {
1212 parent ::__construct (
1313 [
14- 'base_uri ' => $ config ->get ('unleash.url ' ),
14+ 'base_uri ' => $ config ->get ('unleash.url ' ),
1515 ]
1616 );
1717 }
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
1515 public function register ()
1616 {
1717 $ 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+ });
1822 }
1923
2024 /**
@@ -26,11 +30,10 @@ public function boot()
2630 {
2731 $ this ->publishes (
2832 [
29- $ this ->getConfigPath () => config_path ('unleash.php ' ),
33+ $ this ->getConfigPath () => config_path ('unleash.php ' ),
3034 ]
3135 );
3236
33-
3437 Blade::if (
3538 'featureEnabled ' ,
3639 function (string $ feature ) {
You can’t perform that action at this time.
0 commit comments