Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load features config inside FeatureFlagsPlugin::bootstrap #3

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Thumbs.db
#######################
# PHPUnit
.phpunit.cache
.phpunit.result.cache
tests.sqlite
# vim
*~
Expand Down
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ The recommended way to install composer packages is:
composer require markstory/cakephp-feature-flags
```

Next, load the plugin by running the following command:

```
bin/cake plugin load FeatureFlags
```

## Usage

First you need to decide if you want simple boolean feature flags, or more complex
Expand All @@ -39,13 +45,6 @@ return [
];
```

Next, in `config/bootstrap.php` add the following:

```php
// Load the feature configuration during application startup.
Configure::load('features');
```

In your `Application::services()` method add the following:

```php
Expand Down Expand Up @@ -104,13 +103,6 @@ return [
];
```

Next, in `config/bootstrap.php` add the following:

```php
// Load the feature configuration during application startup.
Configure::load('features');
```

In your `Application::services()` method add the following:

```php
Expand Down
17 changes: 13 additions & 4 deletions src/FeatureFlagsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@

use Cake\Console\CommandCollection;
use Cake\Core\BasePlugin;
use Cake\Core\Configure;
use Cake\Core\PluginApplicationInterface;

/**
* Plugin for FeatureFlags
*/
class FeatureFlagsPlugin extends BasePlugin
{
/**
* Add commands for the plugin.
*
* @param \Cake\Console\CommandCollection $commands The command collection to update.
* @return \Cake\Console\CommandCollection
* @inheritDoc
*/
public function console(CommandCollection $commands): CommandCollection
{
Expand All @@ -26,4 +25,14 @@ public function console(CommandCollection $commands): CommandCollection

return $commands;
}

/**
* @inheritDoc
*/
public function bootstrap(PluginApplicationInterface $app): void
{
parent::bootstrap($app);

Configure::load('features');
}
}