Search by

pereval-dating / pereval-bundle

popov100

Symfony bundle for the Pereval dating network partner API

Package info

github.com/pereval-dating/pereval-bundle

Documentation

Type:symfony-bundle

pkg:composer/pereval-dating/pereval-bundle

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-12-04 13:55 UTC

This package is auto-updated.

Last update: 2026-12-04 15:50:30 UTC


README

Version Tests License: MIT API documentation ยท API reference

Connect a Symfony application to the Pereval partner API. The bundle wires pereval-symfony and pereval-php into FrameworkBundle. The HTTP client, logging, webhook handling and middleware remain replaceable.

Installation

Use a maintained PHP and Symfony release in production. The bundle works with Symfony 5.4, 6.4, 7.4 and 8.x on compatible PHP versions.

composer require pereval-dating/pereval-bundle

If Symfony Flex offers the community recipe, review and accept it to set up the bundle, API key, webhook secret and route. If you only need outbound API calls, use the manual setup below without importing the webhook files.

If not already registered, add this entry to config/bundles.php:

Pereval\Bundle\PerevalBundle::class => ['all' => true],

Set PEREVAL_API_KEY in Symfony secrets or your local environment. The default client requires no YAML. Enable FrameworkBundle's HTTP client (framework.http_client: ~) or provide a transport. Verify the key before writes:

php bin/console pereval:check --expect=sandbox

This reads capabilities once and reports mode and protocol. Use --expect=live in production, or omit the option to display either mode. A mismatch or API failure returns 1. Invalid options return 2. Inject Pereval\Client into your services by type, for example:

public function capabilities(\Pereval\Client $client): array
{
    return $client->capabilities->get();
}

Webhooks

If Flex did not install the recipe, copy its two YAML files from the config directory into the corresponding application directories for inbound events. For an HTTP-only client, skip both files. Configure PEREVAL_WEBHOOK_SECRET separately from the API key. Keep real credentials out of version control.

The recipe imports POST /webhooks/pereval. To change the path, replace the import with your own POST route targeting Pereval\Symfony\WebhookController. Allow the partner to reach this endpoint without a browser session. The SDK authenticates the raw request with X-Network-Signature.

Register a listener before enabling deliveries. For example, in config/services.yaml:

services:
    App\Pereval\HandleEvent:
        tags:
            - { name: kernel.event_listener, event: 'Pereval\Symfony\WebhookEvent', method: __invoke }

The listener receives Pereval\Symfony\WebhookEvent. Persist $event->payload transactionally and deduplicate by partner and event ID. The endpoint returns 401 for invalid signatures, 400 for malformed signed payloads and 204 after delivery. Exceptions propagate. The default Symfony dispatcher also fails if no listener is registered.

Messenger

Install symfony/messenger and set pereval.webhooks.bus to messenger.default_bus or a named bus. This replaces synchronous event dispatch. Register a handler for WebhookEvent. To enqueue instead of handling inline, configure a durable transport and a worker, then add:

framework:
    messenger:
        routing:
            'Pereval\Symfony\WebhookEvent': async

A successful queue write acknowledges delivery. The worker owns subsequent retries. Do not enable delivery to a bus that silently allows missing handlers.

Configuration and overrides

Example config/packages/pereval.yaml with optional features:

pereval:
    api_key: '%env(PEREVAL_API_KEY)%'
    origin: 'https://api.pereval.dating'
    http_client: http_client
    logger: monolog.logger.pereval
    profiler: true
    webhooks:
        enabled: true
        secret: '%env(PEREVAL_WEBHOOK_SECRET)%'
        dispatcher: event_dispatcher
        # bus: messenger.default_bus

Logging is off by default. Set logger to an existing PSR-3 service such as logger or a configured Monolog channel. Set commerce_key only if issued. Use a scoped Symfony HTTP client by service ID or bind Pereval\Transport to your own service. The SDK's Psr18Transport accepts a PSR-18 client (e.g. Guzzle) and PSR-17 factories.

Service override Purpose
Pereval\Client Supply a fully configured SDK instance
Pereval\Symfony\ClientFactoryInterface Control client construction
Pereval\Transport Replace HTTP transport
Pereval\Logger Replace SDK metadata logging
Pereval\Symfony\WebhookDecoderInterface Authenticate and decode events
Pereval\Symfony\WebhookSinkInterface Replace event delivery

Bind these IDs to services in the application container. A replacement factory or client owns its middleware and logging. A custom decoder must authenticate the raw body before parsing it. A custom sink must throw on failure.

Autoconfigured implementations of Pereval\Middleware are picked up automatically. For explicit ordering, disable autoconfiguration on the service and use tags: [{ name: pereval.middleware, priority: 100 }]. Higher priority wraps lower priority. Middleware receives sensitive request data. Never log raw requests.

Development

In debug mode with WebProfilerBundle enabled, the Pereval toolbar and panel show method, status and elapsed time. The collector stores no URLs, headers or payloads. Other HTTP profilers and third-party loggers have independent settings. Disable this panel with pereval.profiler: false.

Run composer install and composer test. To include the profiler tests, install symfony/web-profiler-bundle as a development dependency on a compatible PHP version. The suite boots real kernels and uses mock outbound HTTP responses. No partner key or production access is needed. PHP 7.4 and Symfony 5.4 are compatibility targets. Use a maintained PHP and Symfony release in production.

MIT licensed. See LICENSE.