Symfony bundle
counterparty-bundle provides a DI
extension, tagged drivers and research tools, a validator constraint and Messenger
integration. PSR-18 is wired with symfony/http-client’s Psr18Client out of the box.
Installation
composer require gawrys/counterparty-bundle
# config/packages/counterparty.yaml
counterparty:
strategy: rule_based # or "ai"
review_threshold: 0.5
sanctions:
provider: sanctions_network # or "opensanctions"
threshold: 0.7
opensanctions:
api_key: '%env(OPENSANCTIONS_API_KEY)%'
base_uri: '%env(OPENSANCTIONS_BASE_URI)%'
registries:
krs: true
crbr: true
ceidg_token: '%env(CEIDG_TOKEN)%'
regon_token: '%env(REGON_TOKEN)%'
Verify
public function __construct(private \Gawrys\Counterparty\Verifier $verifier) {}
$outcome = $this->verifier->verify(
new \Gawrys\Counterparty\Counterparty('Acme', 'PL', nip: '1234567890'),
);
Tagged registry drivers
Tag a service and a compiler pass collects it into the shared RegistryManager:
services:
App\Registry\GermanRegistryDriver:
arguments: ['@Gawrys\Counterparty\Http\JsonHttpClient']
tags:
- { name: counterparty.registry_driver, alias: de }
Research tools for the AI strategy use the counterparty.research_tool tag.
Validation
use Gawrys\Counterparty\Symfony\Validator\NotSanctioned;
class Supplier
{
#[NotSanctioned(country: 'PL')]
public string $name;
}
Async (Messenger)
Dispatch VerifyCounterpartyMessage; VerifyCounterpartyHandler handles it. Route it to a
transport in config/packages/messenger.yaml as usual.
Enabling AI
Set strategy: ai, install gawrys/counterparty-ai, and define services for
Gawrys\Counterparty\Ai\Research\AiResearchProvider and a PSR-16 CacheInterface. The
bundle registers the AI strategy, prompt builder and tools conditionally (no separate
-ai-symfony package).