qandidate / toggle-api
Api interface for your toggles.
Requires
- php: ^8.2
- ext-json: *
- asm89/stack-cors: ^2.0
- predis/predis: ^3.5
- qandidate/toggle: ^2.0
- qandidate/toggle-bundle: ^2.0
- symfony/dependency-injection: ^6.4 || ^7.4 || ^8.0
- symfony/dotenv: ^6.4 || ^7.4 || ^8.0
- symfony/framework-bundle: ^6.4 || ^7.4 || ^8.0
- symfony/http-foundation: ^6.4 || ^7.4 || ^8.0
- symfony/http-kernel: ^6.4 || ^7.4 || ^8.0
- symfony/security-bundle: ^6.4 || ^7.4 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.5
- symfony/browser-kit: ^6.4 || ^7.4 || ^8.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
An API for managing your toggles, uses Redis to store the toggle collection.
About
Read our blog post series about this repository at:
- http://labs.qandidate.com/blog/2014/08/18/a-new-feature-toggling-library-for-php/
- http://labs.qandidate.com/blog/2014/08/19/open-sourcing-our-feature-toggle-api-and-ui/
Installation
Install the dependencies with composer:
make dependencies
Configuration is determined based on environment variables. See the .env.* files.
You can override the values in the file with environment values.
The default configuration is mainly for local development.
The environment variable TOGGLE__ALLOWED_ORIGINS should be valid JSON. This is to allow arrays.
Running the tests
We use PHPUnit, so to run the tests simply run:
docker-compose up -d
make test
Running the app
With your favorite webserver (or with php -S 127.0.0.1:1337 -t public for local testing) point your document root to the public folder.
Endpoints
Retrieve the toggles
GET /toggles
Create or update a toggle
PUT /toggles/{name}
Example request:
{
"conditions" : [
{
"name" : "operator-condition",
"operator" : {
"name" : "less-than",
"value" : "1337"
},
"key" : "user_id"
}
],
"name" : "foo",
"status" : "conditionally-active",
"originalName" : "foo"
}
NOTE: PUT doesn't remove the previous toggle if you rename it. So if you want to rename foo to bar, you would have to PUT bar and DELETE foo.
Delete a toggle
DELETE /toggles/{name}
License
MIT, see LICENSE.