mcustiel/phiremock-client
PHP client for Phiremock Server with a fluent API to define HTTP expectations, manage scenarios, and reset server state. Works with Guzzle 6 by default, or any PSR-18 HTTP client by overriding the factory for custom connections.
Http::fake(), PestPHP, or PHPUnit) to mock HTTP clients (e.g., Guzzle, Symfony HTTP Client) without reinventing wheel.http/guzzle vs. symfony/http-client). Mitigation: Use the package’s factory override to enforce consistency.Http::fake())? If so, what’s the migration path for existing tests?$this->app->singleton(PhiremockClient::class, function ($app) {
return Factory::createDefault()
->createPhiremockClient(
new Host(config('phiremock.host')),
new Port(config('phiremock.port')),
Scheme::createHttps() // if secure
);
});
Http facade or create a custom facade (e.g., Phiremock) to abstract client interactions.php artisan phiremock:reset).guzzlehttp/guzzle dependency.config/phiremock.php:
return [
'host' => env('PHIREMOCK_HOST', 'localhost'),
'port' => env('PHIREMOCK_PORT', 8080),
'scheme' => env('PHIREMOCK_SCHEME', 'http'),
'secure' => env('PHIREMOCK_SECURE', false),
];
Http::fake(), VCR, or custom solutions).Http::fake()) with Phiremock for reusable expectations.// In TestCase setup/teardown
public function setUp(): void
{
$this->phiremockClient->reset();
parent::setUp();
}
ext-json is enabled (required by the package).ext-json is up-to-date (bug fixes in PHP 8.2+).config/phiremock.php.AppServiceProvider.Http::fake() with Phiremock for targeted test suites.expectRequest() → createExpectation()).- name: Start Phiremock Server
run: docker-compose up -d phiremock
- name: Run Tests
run: php artisan test
- name: Stop Phiremock Server
run: docker-compose down
$this->phiremockClient->listExecutions()->each(function ($execution) {
if ($execution->isFailed()) {
Log::error("Phiremock execution failed: " . $execution->getRequest()->getUri());
}
});
How can I help you explore Laravel packages today?