Download the PHP package ryangjchandler/laravel-feature-flags without Composer

On this page you can find all versions of the php package ryangjchandler/laravel-feature-flags. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-feature-flags

An opinionated feature flags package for Laravel.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package provides an opinionated API for implementing feature flags in your Laravel applications. It supports application-wide features as well as model specific feature flags.

Installation

You can install the package via Composer:

You should then publish and run the migrations with:

You can publish the config file with:

Usage

Global flags

To enable or disable a global feature flag, you can use the Features::enable() and Features::disable() methods respectively.

To check if a flag is enabled or disabled, use the Features::enabled() and Features::disabled() methods respectively.

If you wish to just create a new flag without updating existing ones, i.e. inside of a seeder, you can use Features::add().

This will create a new flag that is disabled by default. To enable the flag by default, provide a boolean value to the enabled argument.

If you simply want to toggle a flag, you can use the Features::toggle() method.

If the flag is enabled, it will be disabled. If it's disabled, it will be enabled.

To get an array of all flags, use the Features::all() method. This will return an array where the flag names are used for the keys and a boolean representing the current state of the flag is the value.

Model flags

If you would like to feature flag specific models, begin by implementing the RyanChandler\LaravelFeatureFlags\Models\Contracts\HasFeatures interface and using the RyanChandler\LaravelFeatureFlags\Models\Concerns\WithFeatures trait. Here's an example on a User model.

The trait provides a default implementation that adheres to the interface. It's recommended that you always use this implementation instead of writing your own.

To enable, disable or toggle a flag, use the same Features::enable(), Features::disable() and Features::toggle() methods by providing a named argument for.

The WithFeatures trait also provides a few helper methods on the model: enableFeature(), disableFeature() and toggleFeature().

Blade directive

This package also provides a set of conditional Blade directives for protecting your views with feature flags.

You can use @elsefeature and @unlessfeature directives too.

If you would like to check a feature flag for a model, you can provide a named argument to the directive.

Middleware

This package provides a piece of middleware to protect your routes with feature flags.

You need to add the following code to your app/Http/Kernel.php file.

You can then register middleware on your route like so:

The default behaviour of the middleware is to abort with a 403 Forbidden status code.

This can be configured in the configuration file by changing the value of middleware.behaviour. The package uses the MiddlewareBehaviour enumeration as the configuration value.

You can change the status code using the middleware.code configuration option.

Redirecting instead of aborting

If you would prefer to redirect instead of aborting, set middleware.behaviour to MiddlewareBehaviour::Redirect and middleware.redirect to your preferred redirect location.

Multiple features

If you wish, you may protect your routes behind multiple feature flags. You can do this by comma-separating the flags passed when defining the middleware on your route definition:

Testing

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.


All versions of laravel-feature-flags with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^9.0
illuminate/database Version ^9.0
spatie/laravel-package-tools Version ^1.9.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ryangjchandler/laravel-feature-flags contains the following files

Loading the files please wait ....