worksome/feature-flags

A package to manage feature flags in your application

Fund package maintenance!
worksome

1.2.0 2022-05-09 08:44 UTC

This package is auto-updated.

Last update: 2022-05-12 20:36:06 UTC


README

PHPStan run-tests

A package to manage feature flags in your application. Currently supporting these providers:

Installation

You can install the package via composer:

composer require worksome/feature-flags

You can publish the config file with:

php artisan vendor:publish --tag="feature-flags_without_prefix-config"

This is the contents of the published config file:

declare(strict_types=1);

use Worksome\FeatureFlags\ModelFeatureFlagConvertor;

// config for Worksome/FeatureFlags
return [
    'default' => env('FEATURE_FLAGS_PROVIDER', 'launchdarkly'),

    'convertor' => ModelFeatureFlagConvertor::class,

    'providers' => [
        'launchdarkly' => [
            'key' => env('LAUNCHDARKLY_SDK_KEY'),
            'options' => [
                /**
                 * https://docs.launchdarkly.com/sdk/features/offline-mode
                 */
                'offline' => env('LAUNCHDARKLY_OFFLINE', false)
            ]
        ]
    ],

    /**
     * Overrides all feature flags directly without hitting the provider.
     * This is particularly useful for running things in the CI,
     * e.g. Cypress tests.
     */
    'override-all' => env('FEATURE_FLAGS_OVERRIDE_ALL'),

    /**
     * Override flags. If a feature flag is set inside an override,
     * it will be used instead of the flag set in the provider.
     *
     * Usage: ['feature-flag-key' => true]
     */
    'overrides' => [],
];

Usage in Blade

@feature('feature-flag')
    This is content under a feature flag.
@endfeature

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.