PHP code example of webrek / laravel-feature-flags
1. Go to this page and download the library: Download webrek/laravel-feature-flags library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webrek / laravel-feature-flags example snippets
use Webrek\FeatureFlags\Facades\Features;
// Define a feature rolled out to 25% of users:
Features::create('new-checkout', rollout: 25);
// Check it (defaults to the authenticated user):
if (Features::active('new-checkout')) {
// ...
}
// Or for a specific scope:
Features::for($user)->active('new-checkout');
use Webrek\FeatureFlags\Contracts\FeatureScope;
class Team extends Model implements FeatureScope
{
public function featureScopeIdentifier(): string
{
return 'team:' . $this->id;
}
public function featureScopeAttributes(): array
{
return ['plan' => $this->plan, 'seats' => $this->seats];
}
}