ylsideas / feature-flags Goto Github PK
View Code? Open in Web Editor NEWA Laravel package for handling feature flags
Home Page: https://feature-flags.docs.ylsideas.co/
License: MIT License
A Laravel package for handling feature flags
Home Page: https://feature-flags.docs.ylsideas.co/
License: MIT License
Hello ๐ ,
From the UPGRADE.md
file it is not clear what we should do with YlsIdeas\FeatureFlags\Middleware\FeatureFlagState
.
In v1, we added the following line within the $routeMiddleware
array in app/Http/Kernel.php
like this:
protected $routeMiddleware = [
...
'feature' => \YlsIdeas\FeatureFlags\Middleware\FeatureFlagState::class,
];
FeatureFlagState
doesn't exist anymore in v2.
What should we do with it as part of the v2 upgrade? Can we just remove it?
And will all our routes defined like in the example below continue to work seamlessly?
// routes/web.php
...
Route::prefix('some-page')->name('some-page.')->middleware('feature:some-feature')->group(function () {
...
Thanks!
2.4.0
8.0.0
9.0.0
No response
No response
The Features::fake()
method in version 2.1.0 causes a problem with installations using the barryvdh/laravel-ide-helper
developer package to generate facade autocompletion for IDEs. Given the popularity of both packages I figured I would report it here.
Everything installs correctly, no dependency problems. But during the post-update scripts (which is the recommended setup by the package) there is an error when running the ide-helper:generate
command.
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"@php artisan ide-helper:generate --ansi",
"@php artisan ide-helper:meta --ansi",
],
sail composer require barryvdh/laravel-ide-helper --dev
sail composer require ylsideas/feature-flags
Then try to run the generate command:
sail artisan ide-helper:generate
ArgumentCountError
Too few arguments to function YlsIdeas\FeatureFlags\Facades\Features::fake(), 0 passed in /var/www/html/vendor/barryvdh/laravel-ide-helper/src/Alias.php on line 220 and exactly 1 expected
at vendor/ylsideas/feature-flags/src/Facades/Features.php:38
34โ /**
35โ * Replace the bound instance with a fake.
36โ * @param array<string, bool|array> $flagsToFake
37โ */
โ 38โ public static function fake(array $flagsToFake): FeatureFake
39โ {
40โ static::swap($fake = new FeatureFake(static::getFacadeRoot(), $flagsToFake));
41โ
42โ return $fake;
+19 vendor frames
20 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
2.1.0
8.1.10
9.45.1
Linux
No response
Shouldn't the error message in this file be:
file could not be found.
?
Upgrade to v2.4.0 from v1.5.0 without updating the config/features.php
configuration and without creating the .features.php
file in the project's root for the in_memory
gateway.
2.4.0
8.0.0
9.0.0
No response
No response
Hey Guys,
I am facing this issue as mentioned at #28 and I am sure that the solution is that PR.
Can @peterfox or @EricTendian merge it?
Tks
If redis cache is empty (flushed), all()
method fails because redis mget
fails with an empty array.
The fix would be to check for empty list of keys before getting the actual content:
if (empty($keys)) {
return [];
}
when I tried Route::get('/some', 'SomeController@show')->middleware('feature:some-feature,off,404')->name('some');
, and this feature flag made true, I want a response to back with 404. But it doesn't.
YlsIdeas\FeatureFlags\Middleware\FeatureFlagState
middleware has check()
function defined by YlsIdeas\FeatureFlags\Support\StateChecking trait. This check()
function return boolean, but it always returns true
.
Is it must be like below?
return $state !== 'off';
I am using Laravel Spark and different plans come with different features. As such it would be nice to be able to use your solution to be able to enable those features via routes/middleware/blade etc but instead of globally enabling disabling features I would need to enable them dynamically based on the user's spark plan. Is this something that you think would be feasible to add as a customization. Do you maybe already have some extension points for this?
Check for multiple feature passed through an array.
I don't know of database, but for config, the php artisan feature:on
and php artisan feature:off
does not change the setting in the configuration file.
Love this package! Great work!
I think it would be good if it was possible to gradually release a feature to x% of users. Maybe by specifying it in the app service provider or a config file and base it on either sessions or users to make it more permanent by adding a column to the users table that stores a json of activated/deactivated features.
Thoughts?
Hi all
I am facing an issue using this Library in the testing environment (feature test) I'm getting the following error:-
Unresolvable dependency resolving [Parameter #0 [ array $config ]] in class YlsIdeas\FeatureFlags\Repositories\InMemoryRepository
env:-
ylsideas/feature-flags = 1.4
laravel/framework = 6.2
php = 7.4
please advice
thanks
I'd like to use this package in a Lumen 8.0 project.
The initial installation appears to work just fine, but when I move to the next stop, vendor:publish
, I'm shown an error. I'm working in a clean branch off master:
$ composer require ylsideas/feature-flags
Using version ^1.5 for ylsideas/feature-flags
./composer.json has been updated
Running composer update ylsideas/feature-flags
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking ylsideas/feature-flags (1.5.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
92 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> TechnologyAdvice\Api\Composer\ComposerScripts::postUpdate
$ php artisan vendor:publish --provider="YlsIdeas\FeatureFlags\FeatureFlagsServiceProvider" --tag=config
Unable to locate publishable resources.
Publishing complete.
I'm comfortable working in Laravel but most of my time has been spent with an existing codebase, rather than being the one installing and configuring new packages. Is there something I'm doing wrong?
Hi, since there's been almost a week since 574a571, is there any chance we'll get a version bump soon?
Thank You
When using chain
repository, only the repository set in store
property is updated when turnOn
/turnOff
, but that change is not reflected when doing ->accessible()
because some upstream repository may return an old value.
I think that turnOn
and turnOff
actions should be replicated in every repository. I'm using the following chain:
redis
: a read cache to improve database accessdatabase
: can override default values if they are presentconfig
: default valuesWith this setup, and choosing database
as repository to store changes, I get redis
still returning the previous values if I turn on or off any feature.
There is a definition of this method on the Features Facade (YlsIdeas\FeatureFlags\Facades\Features) documentation:
Neither the manager class (YlsIdeas\FeatureFlags\Manager) nor any gateway implements this method.
Call:
\YlsIdeas\FeatureFlags\Facades\Features::all();
2.0.2
8.1
9.25.1
Windows
No response
Would it be possible to setup constraints so that only a certain user group will have a feature toggled?
It will be nice to get an artisan command that creates a feature.
This could be either through the php artisan feature:on
or php artisan feature:off
command, that the user is asked to create the feature if it doesn't exist. It could also be through a fresh command like php artisan feature:new
or something
Using 1.4.2 with the following config works fine:
<?php
return [
/*
|--------------------------------------------------------------------------
| default
|--------------------------------------------------------------------------
|
| The repository to use for establishing a feature's on/off state.
|
*/
'default' => 'config',
/*
|--------------------------------------------------------------------------
| Config Feature Switches
|--------------------------------------------------------------------------
|
| This is a set of features to load into the config features repository.
|
*/
'feature' => [
'api' => false,
'api_score' => false,
'api_check' => false,
],
/*
|--------------------------------------------------------------------------
| Repositories
|--------------------------------------------------------------------------
|
| Configures the different repository options
|
*/
'repositories' => [
'config' => [
'key' => 'features.feature',
],
],
];
However on 1.5.0 it seems like the default for some reason ends up being file
and not config
, which in turn results in the fascade always returning false for any feature.
I was looking at using this package and found that the updateOnResolve config option in the config file does nothing. I see there is code in the ChainRepository for handling this feature but it never gets called because the FeatureFlagsServiceProvider register method does not pass the config value through to the ChainRepository on creation.
I tried to enable this feature by modifying the FeatureFlagsServiceProvider to pass the config value and I think I quickly found the reason why this is not enabled. If you use this updateOnResolve feature to update the attempted drivers but then call turnOff or turnOn again the different locations get out of sync.
My question is was this purposely left out and if so is it because of this issue? If so, was there a reason to not just modify the turnOn and turnOff to store the feature state in all levels of the chain if updateOnResolve is enabled?
One solution to this may be to just make the state config option an array instead of a single string so we could tell it to store the values in multiple locations, then updateOnResolve would not really be necessary.
The main reason I'm asking is that I'd like to use the chain driver because I would expect reading from redis would be faster but I'd like to have something a little more permanent like the database driver to fallback on.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.