Skip to content

Commit

Permalink
Support multiple connections config
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-novotny committed May 15, 2023
1 parent 9c21fd6 commit b73a44e
Show file tree
Hide file tree
Showing 14 changed files with 458 additions and 63 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.


## [Unreleased](https://github.com/inspirum/balikobot-php-symfony/compare/v1.0.0...master)
### Added
- Added support for multiple client connections with [**ServiceContainerRegistry**](https://github.com/inspirum/balikobot-php/blob/master/src/Service/Registry/ServiceContainerRegistry.php) service


## v1.0.0 (2022-08-19)
Expand Down
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,38 @@ Configure client credentials by adding `config/packages/balikobot.yaml` and sett

```yaml
balikobot:
api_user: '%env(resolve:BALIKOBOT_API_USER)%'
api_key: '%env(resolve:BALIKOBOT_API_KEY)%'
connections:
default:
api_user: '%env(resolve:BALIKOBOT_API_USER)%'
api_key: '%env(resolve:BALIKOBOT_API_KEY)%'
```
You can use multiple client credentials
```yaml
balikobot:
connections:
client1:
api_user: '%env(resolve:BALIKOBOT_API_USER_1)%'
api_key: '%env(resolve:BALIKOBOT_API_KEY_1)%'
client2:
api_user: '%env(resolve:BALIKOBOT_API_USER_2)%'
api_key: '%env(resolve:BALIKOBOT_API_KEY_2)%'
client3:
api_user: '%env(resolve:BALIKOBOT_API_USER_3)%'
api_key: '%env(resolve:BALIKOBOT_API_KEY_3)%'
```
Then use `ServiceContainerRegistry` to get `ServiceContainer` for given connection.

```php
/** @var Inspirum\Balikobot\Service\Registry\ServiceContainerRegistry $registry */
// get package service for default (or first) connection
$packageService = $registry->get()->getPackageService();
// get branch service for "client3" connection
$packageService = $registry->get('client3')->getBranchService();
```

## Contributing
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
"ext-curl": "*",
"ext-json": "*",
"guzzlehttp/psr7": "^2.0",
"inspirum/arrayable": "^1.1",
"inspirum/balikobot": "^7.0",
"inspirum/arrayable": "^1.2",
"inspirum/balikobot": "dev-master",
"psr/http-message": "^1.0",
"symfony/config": "^6.1",
"symfony/dependency-injection": "^6.1",
"symfony/http-kernel": "^6.1"
},
"require-dev": {
"inspirum/coding-standard": "^1.3",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.7",
"symfony/yaml": "^6.1"
Expand Down
6 changes: 5 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ parameters:
paths:
- src
- tests
ignoreErrors: []
ignoreErrors:
-
message: '#^Cannot call method scalarNode\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface\|null\.$#'
count: 1
path: src/BalikobotBundle.php
8 changes: 5 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="var/phpunit/logs/clover.xml"/>
<text outputFile="var/phpunit/coverage/coverage.txt"/>
</report>
</coverage>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
Loading

0 comments on commit b73a44e

Please sign in to comment.