From d6d753611a0eecb911bfbfdee3ac129f67cde097 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Fri, 15 Nov 2024 09:05:27 +1100 Subject: [PATCH 1/2] Document defining features externally --- pennant.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pennant.md b/pennant.md index c0783ae1b3..7cb80e3749 100644 --- a/pennant.md +++ b/pennant.md @@ -28,6 +28,7 @@ - [Adding Custom Pennant Drivers](#adding-custom-pennant-drivers) - [Implementing the Driver](#implementing-the-driver) - [Registering the Driver](#registering-the-driver) + - [Defining Features Externally](#defining-features-externally) - [Events](#events) @@ -1022,7 +1023,7 @@ class RedisFeatureDriver implements Driver Now, we just need to implement each of these methods using a Redis connection. For an example of how to implement each of these methods, take a look at the `Laravel\Pennant\Drivers\DatabaseDriver` in the [Pennant source code](https://github.com/laravel/pennant/blob/1.x/src/Drivers/DatabaseDriver.php) -> [!NOTE] +> [!NOTE] > Laravel does not ship with a directory to contain your extensions. You are free to place them anywhere you like. In this example, we have created an `Extensions` directory to house the `RedisFeatureDriver`. @@ -1075,6 +1076,29 @@ Once the driver has been registered, you may use the `redis` driver in your appl ], + +#### Defining Features Externally + +If your driver is a wrapper around a 3rd-party feature flag platform, you will likely define features on the platform rather than using Pennant's `Feature::define` method. If that is the case, your custom driver should also implement the `Laravel\Pennant\Contracts\DefinesFeaturesExternally` interface: + +```php + ## Events From 3aaa357c672e8dc170dbab48d6d5d795a13e6205 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 15 Nov 2024 08:50:57 -0600 Subject: [PATCH 2/2] Update pennant.md --- pennant.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pennant.md b/pennant.md index 7cb80e3749..fd9c757fc4 100644 --- a/pennant.md +++ b/pennant.md @@ -1077,9 +1077,9 @@ Once the driver has been registered, you may use the `redis` driver in your appl ], -#### Defining Features Externally +### Defining Features Externally -If your driver is a wrapper around a 3rd-party feature flag platform, you will likely define features on the platform rather than using Pennant's `Feature::define` method. If that is the case, your custom driver should also implement the `Laravel\Pennant\Contracts\DefinesFeaturesExternally` interface: +If your driver is a wrapper around a third-party feature flag platform, you will likely define features on the platform rather than using Pennant's `Feature::define` method. If that is the case, your custom driver should also implement the `Laravel\Pennant\Contracts\DefinesFeaturesExternally` interface: ```php ## Events