You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you create your own toggles, you may need to introduce additional context
50
-
to the toggle to check if everything should be enabled or disabled. This is
51
-
where this comes into play at.
51
+
When you create your own toggles, you may need to introduce additional context to the toggle to check if everything should be enabled or disabled. This is where this comes into play at.
52
52
53
-
### Chain Toggle
53
+
####Chain Toggle
54
54
55
-
The chain toggle allows you to use many toggles together. If ANY toggle returns
56
-
`true`, the feature is considered enabled.
55
+
The chain toggle allows you to use many toggles together. If ANY toggle returns `true`, the feature is considered enabled.
57
56
58
57
```php
59
58
<?php
@@ -71,10 +70,9 @@ $toggle = new ChainToggle([
71
70
$isEnabled = $toggle->isEnabled();
72
71
```
73
72
74
-
### Affirmative Toggle
73
+
####Affirmative Toggle
75
74
76
-
Similar to the chain toggle, this will only return `true` when ALL toggles are
77
-
`true`.
75
+
Similar to the chain toggle, this will only return `true` when ALL toggles are `true`.
78
76
79
77
```php
80
78
<?php
@@ -92,7 +90,7 @@ $toggle = new ChainToggle([
92
90
$isEnabled = $toggle->isEnabled();
93
91
```
94
92
95
-
### Date Range Toggle
93
+
####Date Range Toggle
96
94
97
95
The date range toggle will return `true` if it's within a given time range.
98
96
@@ -101,19 +99,17 @@ The date range toggle will return `true` if it's within a given time range.
101
99
102
100
use SonsOfPHP\Component\FeatureToggle\Toggle\DateRangeToggle;
103
101
104
-
$toggle = new ChainToggle(
102
+
$toggle = new DateRangeToggle(
105
103
start: new \DateTimeImmutable('2024-01-01'),
106
104
end: new \DateTimeImmutable('2024-12-31'),
107
105
);
108
106
109
107
// ...
110
108
```
111
109
112
-
## Create your own Toggle
110
+
###Create your own Toggle
113
111
114
-
Take a look at how some of the other toggles are implemented. Creating your own
115
-
toggles are very easy. You just need to make sure they implement the interface
116
-
`ToggleInterface`.
112
+
Take a look at how some of the other toggles are implemented. Creating your own toggles are very easy. You just need to make sure they implement the interface `ToggleInterface`.
117
113
118
114
```php
119
115
<?php
@@ -130,5 +126,4 @@ class MyCustomToggle implements ToggleInterface
130
126
}
131
127
```
132
128
133
-
Once you make your custom toggle, you can use it just like all the rest of the
134
-
toggles.
129
+
Once you make your custom toggle, you can use it just like all the rest of the toggles.
Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md) of the Composer documentation.
6
+
7
+
### Applications that use Symfony Flex
8
+
9
+
Open a command console, enter your project directory and execute:
10
+
11
+
```sh
12
+
composer require sonsofphp/feature-toggle-bundle
13
+
```
14
+
15
+
### Applications that don't use Symfony Flex
16
+
17
+
#### Step 1: Download the Bundle
18
+
19
+
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
20
+
21
+
```sh
22
+
composer require sonsofphp/feature-toggle-bundle
23
+
```
24
+
25
+
#### Step 2: Enable the Bundle
26
+
27
+
Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:
0 commit comments