Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/area17/twill-feature-flags
https://github.com/area17/twill-feature-flags
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/area17/twill-feature-flags
- Owner: area17
- License: apache-2.0
- Created: 2022-03-30T13:01:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-10T07:55:11.000Z (4 months ago)
- Last Synced: 2024-10-27T13:28:37.148Z (14 days ago)
- Language: PHP
- Size: 624 KB
- Stars: 7
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: .github/SECURITY.md
Awesome Lists containing this project
- awesome-twill - Feature Flags - This Capsule allows you to easily enable/disable features on your application (Packages)
README
# Feature Flags
## Twill Capsule### Description
This Capsule allows you to easily enable/disable features on your application. Features not flagged to be available publicly will still be available on non-public domains. This way company staff and QA teams can still test these features on hiden domains, even if they are served by the same server/database.
![Screenshot 1](docs/screenshot01.png)
![Screenshot 2](docs/screenshot02.png)
## Installing
Require the Composer package:
``` bash
composer require area17/twill-feature-flags
```Enable the Capsule in config/twill.php:
``` php
'capsules' => [
'list' => [
[
'name' => 'FeatureFlags',
'enabled' => true,
],
...
```Load Capsule helpers by adding calling the loader to your AppServiceProvider:
``` php
/**
* Register any application services.
*
* @return void
*/
public function register()
{
\A17\TwillFeatureFlags\Services\Helpers::load();
}
```Add a configuration to config/app.php, to set your public available domains
``` php
/*
|--------------------------------------------------------------------------
| Domains
|--------------------------------------------------------------------------
|
*/'domains' => [
'publicly_available' => explode(',', env('PUBLICLY_AVAILABLE_DOMAINS')),
],
```
Add the production domains list (comma separated) to your .env file:``` dotenv
PUBLICLY_AVAILABLE_DOMAINS=my-production-domain.com
```## Using
Once installed and configured, you can go to https://your-domain/featureFlags to create/enable/disable feature flags.
And, on your code, you can just use the helper to show/hide features from your website:
``` php
if (feature('booking')) {
// whatever your feature has to do
}
```Or in Blade:
``` php
@include('partials.global.head', ['noIndex' => !feature('feature-x')])@if(feature('booking'))
// Render the feature
@endif
```Don't forget to add the feature flags to your navigation too.
## Allow users logged in Twill option
You can allow your users to have access to a feature in public available domains if they are logged in on Twill. But there are some caveats for it to work:- Twill must be int he same domain of the web application, meaning that `ADMIN_APP_URL` must be empty or have the same domain as the frontend; or
- The Laravel session domain should set in order for the apps to share the session cookie:```dotenv
SESSION_DOMAIN=.laravel-twill-project.test
```Also, make sure your sessions are working fine, when you switch to a shared domain they might break and a browser cookie clear might be needed.