Symfony

Symfony

Installation

1
composer require botbye/botbye-php-sdk

Configuration

Wire the standalone BotbyePhishingClient as a Symfony service. Phishing is separate from the evaluate BotbyeClient, is identified by a public, browser-safe clientKey, and only needs a PSR-18 HTTP client and a PSR-17 request factory (no server key, no stream factory). Wired as a singleton service, on first use it makes a one-off, process-wide-guarded, best-effort server-integration init handshake that reports this server-side integration to BotBye; it is non-blocking.

Getting clientKey

clientKey is the public, browser-safe identifier of your phishing project. It travels in the asset URL path, so it is safe to expose — no secret token and no Base64 encoding are required.

Find it on the Get Started screen of your phishing project in the BotBye dashboard.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# config/services.yaml
services:
    _defaults:
        autowire: true
        autoconfigure: true

    # PSR-17 Factory
    Nyholm\Psr7\Factory\Psr17Factory: ~

    # PSR-18 HTTP Client
    botbye.http_client:
        class: Symfony\Component\HttpClient\Psr18Client

    Botbye\Phishing\BotbyePhishingConfig:
        arguments:
            $endpoint: 'https://verify.botbye.com'
            $clientKey: '<public-client-key>'

    Botbye\Phishing\BotbyePhishingClient:
        arguments:
            $config: '@Botbye\Phishing\BotbyePhishingConfig'
            $httpClient: '@botbye.http_client'
            $requestFactory: '@Nyholm\Psr7\Factory\Psr17Factory'

Usage

Expose a single controller action that proxies phishing pixel requests.

When you use an SVG image, your application must also expose an endpoint on the client origin that handles requests to /{imageId}.png, where imageId is the value that arrives in the forwarded pixel query as image_id.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

namespace App\Controller;

use Botbye\Phishing\BotbyePhishingClient;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class PhishingController extends AbstractController
{
    public function __construct(
        private BotbyePhishingClient $phishing
    ) {
    }

    #[Route('/api/phishing/image', methods: ['GET'])]
    public function image(Request $request): Response
    {
        $origin = $request->headers->get('Origin');
        $res = $this->phishing->fetchImageFromRequest($request, $request->query->all());

        if ($res->error !== null) {
            return new Response($res->error->message, 502);
        }

        $contentType = $res->headers['Content-Type'] ?? 'image/png';

        return new Response($res->body, $res->status, ['Content-Type' => $contentType]);
    }
}

Settings

Configuration parameters for phishing integration:

Setting Description Required Default Value
endpoint Host of the phishing API no https://verify.botbye.com
clientKey Public client-key of your phishing project yes -