Keploy logo
Symfony logo

Keploy as a Symfony testing framework

Keploy tests Symfony applications by recording real requests through the running server and every Doctrine query or HttpClient call they trigger, then replaying both as assertions. No test kernel boots and no fixtures are loaded.

Generate Symfony tests free
keploy record -c "symfony server:start --no-tls"
18.4K+VS Code1.2M+300M+mocks created

What Keploy gives a Symfony team

Any Symfony app, unchanged

Keploy runs the app through the Symfony CLI server, FrankenPHP, or PHP-FPM. Event listeners, the security firewall, and ParamConverters all execute because capture is at the socket.

  • Symfony 6 and 7
  • CLI server, FrankenPHP, or FPM
  • Event listeners and subscribers run
  • Security firewall genuinely exercised
The problem

Why Symfony integration tests slow teams down

The friction is rarely the assertions. It is everything around them — spinning up dependencies, keeping mocks honest, and repairing tests after every refactor.

Three ways to do it

Testing Symfony: by hand, with PHPUnit + Guzzle MockHandler, or with Keploy

WebTestCase boots a kernel in the test environment with fixtures loaded. Keploy records the running app under production configuration, so neither diverges from what you deploy.

Select any row for the full comparison, with code.

Same coverage, three costs

What you write for Symfony vs what Keploy records

All three produce the same assertion. Only the third still passes after the next refactor without anyone editing it.

By hand2–4 hours
OrderControllerTest.php
hand-written
<?php
// Hand-written: a stub repository bound into the container.
use PHPUnit\Framework\TestCase;
 
final class OrderControllerTest extends TestCase
{
public function testConfirmsAnAuthorizedOrder(): void
{
$repo = $this->createMock(OrderRepository::class);
$repo->method('find')->willReturn(
new Order('ord_1', 4200, 'NEW'),
);
 
$controller = new OrderController($repo, new FakePayments());
$response = $controller->confirm('ord_1', new Request([], ['payment_token' => 'tok_123']));
 
self::assertSame(200, $response->getStatusCode());
}
}

The controller is constructed by hand, so the firewall, ParamConverter, and every event listener are absent from what this proves.

PHPUnit + Guzzle MockHandler1–2 hours
OrderControllerFunctionalTest.php
tool-assisted
<?php
// WebTestCase + fixtures + MockHttpClient.
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
 
final class OrderControllerFunctionalTest extends WebTestCase
{
public function testConfirmsAnAuthorizedOrder(): void
{
// Boots the kernel in the test environment.
$client = static::createClient();
$this->loadFixtures([OrderFixtures::class]);
 
// A literal that will not change when Stripe does.
static::getContainer()->set(HttpClientInterface::class, new MockHttpClient(
new MockResponse('{"status":"AUTHORIZED"}'),
));
 
$client->jsonRequest('POST', '/orders/ord_1/confirm', ['payment_token' => 'tok_123']);
 
self::assertResponseIsSuccessful();
}
}

Drives the real kernel, which is right — and under the test environment, with fixtures and a MockHttpClient response typed out by hand.

With Keploy~5 minutes
test-1.yaml
auto-generated
# Recorded with: keploy record -c 'symfony server:start --no-tls'
# Nobody wrote this file. Keploy captured it from a real request.
version: api.keploy.io/v1beta1
kind: Http
name: test-1
spec:
req:
method: POST
url: /orders/ord_1/confirm
body: '{"paymentToken":"tok_123"}'
resp:
status_code: 200
body:
id: "ord_1"
state: "CONFIRMED"
amountMinor: 4200
noise:
- body.confirmedAt
mocks:
- kind: MySQL
operation: "SELECT t0.id AS id_1, t0.amount_minor AS amount_minor_2 FROM orders t0 WHERE t0.id = ?"
- kind: Http
url: https://api.payments.example.com/v1/payment_intents/tok_123/confirm

Recorded under the configuration you deploy, so an env-conditional service or a cache setting that only differs in the test environment cannot hide a bug here.

Times are estimates for authoring one endpoint’s coverage from scratch, not measurements.

Keploy vs the alternatives

Symfony testing tools, compared

The options a team on PHP actually reaches for, and where each one genuinely wins. Select a row for the full comparison.

Best in classStrongPartialNot covered

Assessments reflect each tool’s documented behaviour, not benchmark measurements.

How it works

Record your Symfony app once, replay it forever

Keploy sits below your Symfony process at the network layer. It watches the calls your app already makes, then serves them back on replay so tests run with no dependencies attached.

Keploy records a GET call to /api/v1/orders/{id} on a Symfony service and captures the dependency calls it makes.

Symfony logo
Your Symfony app
GET/api/v1/orders/{id}200
RecordingKeploy proxyeBPF · userspace
+3 more Symfony dependencies
An example shape of a captured call. Your own endpoints and dependencies come from your real traffic, so nothing here has to be written by hand.
Mock coverage

What Keploy mocks for Symfony, with zero config

7 of the 7 dependencies a typical Symfony service talks to are stubbed from the recording itself — no mock classes, no fixture files, no containers in CI.

Quick start

Your first Symfony test suite in under five minutes

Every command below runs against your existing Symfony service. Nothing in your source tree changes.

  1. 1Install the Keploy CLI

    A single binary. It needs a Linux kernel with eBPF support, or Docker on macOS and Windows — and it adds nothing to your project's dependencies.

    curl -sSL https://keploy.io/install.sh | bash
  2. 2Record your service

    Pass the command you already use to start the app. Keploy runs it and watches every socket it opens.

    keploy record -c "symfony server:start --no-tls"
  3. 3Exercise the paths you care about

    Drive the running server. Every request becomes a test case with its database and HTTP calls captured alongside.

    curl -X POST localhost:8000/orders/ord_1/confirm -H 'Content-Type: application/json' -d '{"payment_token":"tok_123"}'
  4. 4Replay in CI

    Replay serves the recorded dependency responses, so the job needs no service containers and no Docker daemon.

    keploy test -c "symfony server:start --no-tls" --delay 8

Ready to try it on your own Symfony service?

Ecosystem

Works with the rest of your Symfony stack

Keploy records at the network layer, so framework and driver choices inside your Symfony app do not change how it captures traffic.

FAQ

Symfony testing with Keploy: common questions

Join our GlobalCommunity

Connect with developers worldwide. Follow updates, ask questions, share feedback, and ship faster with other Keploy builders.

1.2M+Installs
18.4K+GitHub
100K+Devs
300M+Mocks
1K+Contributors
#1OSS Trending
4.9★★★★★from 500+ reviews onG2GartnerVS CodeChrome
★★★★★

Best report of integration and API tests I've seen — which we don't get from RestAssured.

G2
★★★★★

Future of microservices testing. I don't write tests now!

G2 · 5/5
★★★★★

An amazing product that simplifies the automation.

Gartner · 4.0
XGitHubSlackYouTubeLinkedIn
Built by developers, for developers.Let's build the future, together.