Skip to content

Commit

Permalink
feature toggle bundle (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaEstes authored Oct 23, 2024
1 parent ba79778 commit ca1022b
Show file tree
Hide file tree
Showing 61 changed files with 537 additions and 11 deletions.
14 changes: 12 additions & 2 deletions bard.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
},
{
"path": "src/SonsOfPHP/Bundle/Cqrs",
"repository": "[email protected]:SonsOfPHP/cqrs-bundle.git"
"repository": "[email protected]:SonsOfPHP/cqrs-bundle.git",
"config": {
"merge": false
}
},
{
"path": "src/SonsOfPHP/Bridge/Symfony/Cqrs",
Expand Down Expand Up @@ -188,6 +191,13 @@
{
"path": "src/SonsOfPHP/Contract/Version",
"repository": "[email protected]:SonsOfPHP/version-contract.git"
},
{
"path": "src/SonsOfPHP/Bundle/FeatureToggleBundle",
"repository": "[email protected]:SonsOfPHP/feature-toggle-bundle.git",
"config": {
"merge": false
}
}
]
}
}
14 changes: 6 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"homepage": "https://github.com/SonsOfPHP",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down Expand Up @@ -79,11 +83,8 @@
"psr/log": "^2.0 || ^3.0",
"psr/simple-cache": "^2.0 || ^3.0",
"symfony/console": "^4 || ^5 || ^6 || ^7",
"symfony/dependency-injection": "^5 || ^6 || ^7",
"symfony/dotenv": "^5 || ^6 || ^7",
"symfony/finder": "^5 || ^6 || ^7",
"symfony/http-kernel": "^5 || ^6 || ^7",
"symfony/messenger": "^5 || ^6 || ^7",
"symfony/options-resolver": "^6 || ^7",
"symfony/process": "^5 || ^6 || ^7",
"symfony/security-bundle": "^6 || ^7",
Expand All @@ -100,7 +101,6 @@
"sonsofphp/cookie": "self.version",
"sonsofphp/cookie-contract": "self.version",
"sonsofphp/cqrs": "self.version",
"sonsofphp/cqrs-bundle": "self.version",
"sonsofphp/cqrs-contract": "self.version",
"sonsofphp/cqrs-symfony": "self.version",
"sonsofphp/event-dispatcher": "self.version",
Expand Down Expand Up @@ -150,7 +150,6 @@
"src/SonsOfPHP/Component/Container/Tests",
"src/SonsOfPHP/Component/Cookie/Tests",
"src/SonsOfPHP/Component/Cqrs/Tests",
"src/SonsOfPHP/Bundle/Cqrs/Tests",
"src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests",
"src/SonsOfPHP/Bridge/Symfony/EventSourcing/Tests",
"src/SonsOfPHP/Bridge/Twig/Money/Tests",
Expand Down Expand Up @@ -186,7 +185,6 @@
"SonsOfPHP\\Bridge\\Symfony\\Cqrs\\": "src/SonsOfPHP/Bridge/Symfony/Cqrs",
"SonsOfPHP\\Bridge\\Symfony\\EventSourcing\\": "src/SonsOfPHP/Bridge/Symfony/EventSourcing",
"SonsOfPHP\\Bridge\\Twig\\Money\\": "src/SonsOfPHP/Bridge/Twig/Money",
"SonsOfPHP\\Bundle\\Cqrs\\": "src/SonsOfPHP/Bundle/Cqrs",
"SonsOfPHP\\Component\\Assert\\": "src/SonsOfPHP/Component/Assert",
"SonsOfPHP\\Component\\Cache\\": "src/SonsOfPHP/Component/Cache",
"SonsOfPHP\\Component\\Clock\\": "src/SonsOfPHP/Component/Clock",
Expand Down Expand Up @@ -234,13 +232,13 @@
"require-dev": {
"phpunit/phpunit": "^10.4",
"symfony/http-foundation": "^5 || ^6 || ^7",
"symfony/messenger": "^5 || ^6 || ^7",
"symfony/serializer": "^5 || ^6 || ^7"
},
"autoload-dev": {
"psr-4": {
"SonsOfPHP\\Bard\\Tests\\": "src/SonsOfPHP/Bard/Tests",
"SonsOfPHP\\Bridge\\Symfony\\Cqrs\\Tests\\": "src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests",
"SonsOfPHP\\Bundle\\Cqrs\\Tests\\": "src/SonsOfPHP/Bundle/Cqrs/Tests"
"SonsOfPHP\\Bridge\\Symfony\\Cqrs\\Tests\\": "src/SonsOfPHP/Bridge/Symfony/Cqrs/Tests"
}
},
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bard/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
"docs": "https://docs.sonsofphp.com"
},
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
7 changes: 7 additions & 0 deletions src/SonsOfPHP/Bard/src/Console/Command/MergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
;

foreach ($this->bardConfig->getSection('packages') as $pkg) {
if (array_key_exists('config', $pkg) && array_key_exists('merge', $pkg['config']) && false === $pkg['config']['merge']) {
// Do not merge this package
continue;
}

$pkgComposerFile = realpath($input->getOption('working-dir') . '/' . $pkg['path'] . '/composer.json');
if (!file_exists($pkgComposerFile)) {
$output->writeln(sprintf('No "%s" found, skipping', $pkgComposerFile));
Expand Down Expand Up @@ -116,6 +121,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io->text(sprintf('Updated "%s"', $rootComposerJsonFile->getRealPath()));
}

// @todo if not dry-run, run composer dump

$io->success('Merge Complete');

return self::SUCCESS;
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bridge/Aws/Filesystem/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"homepage": "https://github.com/SonsOfPHP/filesystem-aws",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bridge/Doctrine/Collections/Pager/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"homepage": "https://github.com/SonsOfPHP/pager-doctrine-collections",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bridge/Doctrine/DBAL/Pager/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"homepage": "https://github.com/SonsOfPHP/pager-doctrine-dbal",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bridge/Doctrine/EventSourcing/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"homepage": "https://github.com/SonsOfPHP/event-sourcing",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bridge/Doctrine/ORM/Pager/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"homepage": "https://github.com/SonsOfPHP/pager-doctrine-orm",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bridge/LiipImagine/Filesystem/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
"homepage": "https://github.com/SonsOfPHP/filesystem-liip-imagine",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bridge/Symfony/Cqrs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"homepage": "https://github.com/SonsOfPHP/cqrs-symfony",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bridge/Symfony/EventSourcing/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"homepage": "https://github.com/SonsOfPHP/event-sourcing-symfony",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
4 changes: 4 additions & 0 deletions src/SonsOfPHP/Bridge/Twig/Money/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"homepage": "https://github.com/SonsOfPHP/money",
"license": "MIT",
"authors": [
{
"name": "Sons of PHP Community",
"homepage": "https://github.com/SonsOfPHP/sonsofphp/graphs/contributors"
},
{
"name": "Joshua Estes",
"email": "[email protected]"
Expand Down
19 changes: 19 additions & 0 deletions src/SonsOfPHP/Bundle/FeatureToggleBundle/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright 2022 to Present Joshua Estes

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 23 additions & 0 deletions src/SonsOfPHP/Bundle/FeatureToggleBundle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div align="center">
<img src="https://raw.githubusercontent.com/SonsOfPHP/.github/main/assets/top-rocker.png" />
</div>
<br/>
<div align="center">
<a href="https://codecov.io/github/SonsOfPHP/sonsofphp"><img src="https://codecov.io/github/SonsOfPHP/sonsofphp/graph/badge.svg?token=VZ2FVOUKUW" /></a>
<img src="https://img.shields.io/packagist/l/sonsofphp/sonsofphp" />
<img src="https://img.shields.io/packagist/v/sonsofphp/sonsofphp" />
</div>

# Sons of PHP

Sons of PHP is builds reusable components and tools using PHP.

* Documentation can be found at [docs.SonsOfPHP.com][docs]
* Please [Report Issues][issues] and send [Pull Requests][pull-requests] in the [Mother Repository][mother-repo]
* You can get more help by posting questions in the [GitHub Discussions][discussions]

[mother-repo]: <https://github.com/SonsOfPHP/sonsofphp> "Sons of PHP Mother Repository"
[discussions]: https://github.com/orgs/SonsOfPHP/discussions
[issues]: https://github.com/SonsOfPHP/sonsofphp/issues
[pull-requests]: https://github.com/SonsOfPHP/sonsofphp/pulls
[docs]: https://docs.sonsofphp.com
56 changes: 56 additions & 0 deletions src/SonsOfPHP/Bundle/FeatureToggleBundle/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "sonsofphp/feature-toggle-bundle",
"type": "symfony-bundle",
"description": "Sons of PHP | Feature Toggle Bundle",
"keywords": [
"sonsofphp",
"sons of php",
"feature",
"toggle",
"feature toggle",
"symfony"
],
"homepage": "https://github.com/SonsOfPHP/feature-toggle-bundle",
"license": "MIT",
"authors": [
{
"name": "Joshua Estes",
"email": "[email protected]"
}
],
"support": {
"issues": "https://github.com/SonsOfPHP/sonsofphp/issues",
"forum": "https://github.com/orgs/SonsOfPHP/discussions",
"docs": "https://docs.sonsofphp.com/symfony-bundles/feature-toggle"
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/JoshuaEstes"
},
{
"type": "tidelift",
"url": "https://tidelift.com/subscription/pkg/packagist-sonsofphp-sonsofphp"
}
],
"require": {
"php": ">=8.2",
"sonsofphp/feature-toggle": "^0.3@dev"
},
"autoload": {
"psr-4": {
"SonsOfPHP\\Bundle\\FeatureToggleBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"SonsOfPHP\\Bundle\\FeatureToggleBundle\\Tests\\": "tests/"
}
},
"extra": {
"sort-packages": true,
"branch-alias": {
"dev-main": "0.3.x-dev"
}
}
}
40 changes: 40 additions & 0 deletions src/SonsOfPHP/Bundle/FeatureToggleBundle/config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
services:
SonsOfPHP\Bundle\FeatureToggleBundle\Command\DebugCommand:
arguments: ['@sons_of_php.feature_toggle.provider']
tags:
- { name: 'console.command' }

SonsOfPHP\Bundle\FeatureToggleBundle\Twig\Extension\FeatureToggleExtension:
tags:
- { name: 'twig.extension' }

SonsOfPHP\Bundle\FeatureToggleBundle\Twig\Runtime\FeatureToggleExtensionRuntime:
arguments: ['@sons_of_php.feature_toggle.provider']
tags:
- { name: 'twig.runtime' }

SonsOfPHP\Component\FeatureToggle\Toggle\AlwaysDisabledToggle:
tags:
- { name: 'sons_of_php.feature_toggle.toggle' }

sons_of_php.feature_toggle.toggle.disabled:
alias: SonsOfPHP\Component\FeatureToggle\Toggle\AlwaysDisabledToggle
public: true

SonsOfPHP\Component\FeatureToggle\Toggle\AlwaysEnabledToggle:
tags:
- { name: 'sons_of_php.feature_toggle.toggle' }

sons_of_php.feature_toggle.toggle.enabled:
alias: SonsOfPHP\Component\FeatureToggle\Toggle\AlwaysEnabledToggle
public: true

# The provider contains all the different features and their toggles Default
# provider should be a chain provider so that users can define additional
# providers
SonsOfPHP\Contract\FeatureToggle\FeatureToggleProviderInterface:
class: SonsOfPHP\Component\FeatureToggle\Provider\InMemoryFeatureToggleProvider

sons_of_php.feature_toggle.provider:
alias: SonsOfPHP\Contract\FeatureToggle\FeatureToggleProviderInterface
public: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

namespace SonsOfPHP\Bundle\FeatureToggleBundle\Attribute;

final class AsFeature {}
Loading

0 comments on commit ca1022b

Please sign in to comment.