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

On this page you can find all versions of the php package codinglabsau/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

Dynamic Feature Flags for Laravel

Latest Version on Packagist Test Total Downloads

Laravel Feature Flags allows instant, zero-deployment toggling of application features.

The state of each feature flag can be checked from anywhere in the application code (including via a @feature('name') blade directive) to determine whether the conditions you set have been met to enable the feature.

Each feature can be in one of three states:


Installation

Install With Composer

Database Migrations

Publish Configuration

Set Your Cache Store

This package caches the state of features to reduce redundant database queries. The cache is expired whenever the feature state changes.

By default, this package will use the default cache configured in your application.

If you wish to change to a different cache driver, update your .env:

Usage

Create a new feature in the database and set the initial state:

Its recommended that you seed the features to your database before a new deployment or as soon as possible after a deployment.

Check If A Feature Is Enabled

Blade View

Use the @feature blade directive anywhere in your view files.

In Your Code

Use the FeatureFlag facade to conveniently check the state of a feature in your app code.

Middleware

Register feature as a route middleware in your HTTP Kernel to protect routes. A 404 response will be returned if the feature does not resolve to the on state.

Check If A Feature Is Disabled

Blade View

In Your Code

Get The Underlying Current State

If you want to know what the underlying FeatureState value is:

Updating Feature State

To change the state of a feature you can call the following methods:

Alternatively you can set the state directly by passing a feature state enum:

It is recommended that you only update a features state using the above methods as it will take care of flushing the cache and dispatching the feature updated event:

You should listen for the FeatureUpdatedEvent event if you have any downstream implications when a feature state is updated, such as invalidating any cached items that are referenced in dynamic handlers.


Advanced Usage

Dynamic Features

A dynamic handler can be defined in the boot() method of your AppServiceProvider:

Dynamic handlers will only be called when a feature is in the dynamic state. This will allow you to define custom rules around whether that feature is enabled like in the example above where the user can only access the feature if they have a tester role.

Each handler is provided with the features name and current request as arguments and must return a boolean value.

Default Handler For Dynamic Features

You may also define a default handler which will be the catch-all handler for features that don't have an explicit handler defined for them:

An explicit handler defined using registerDynamicHandler() will take precedence over the default handler. If neither a default nor explicit handler has been defined then the feature will resolve to off by default.

Handle Missing Features

Features must exist in the database otherwise a MissingFeatureException will be thrown. This behaviour can be turned off by explicitly handling cases where a feature doesn't exist:

If a handler for missing features has been defined then an exception will not be thrown and the feature will resolve to off.

Using Your Own Model

To use your own model, update the config and replace the existing reference with your own model:

Make sure to also cast the state column to a feature state enum using the FeatureStateCast:

Sharing features with UI (Inertiajs example)

Testing

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 ^10.0|^11.0
spatie/laravel-package-tools Version ^1.14.1
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 codinglabsau/laravel-feature-flags contains the following files

Loading the files please wait ....