jeroen/post-request-sender

Micro library with interface for sending post requests. Includes test doubles and adapters

Maintainers

👁 Jeroen De Dauw

Package info

github.com/JeroenDeDauw/PostRequestSender

pkg:composer/jeroen/post-request-sender

Fund package maintenance!

JeroenDeDauw

Statistics

Installs: 33 320

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.0.0 2022-02-03 22:27 UTC

Requires

Requires (Dev)

Suggests

Provides

None

Conflicts

None

Replaces

None

GPL-2.0-or-later 9c22630abb0f6ef890d8ba27325ba245a7f462e9

This package is auto-updated.

Last update: 2026-06-14 23:38:45 UTC


README

👁 Build Status
👁 codecov
👁 Type Coverage
👁 Psalm level
👁 Latest Stable Version
👁 Download count

Micro library with PostRequestSender interface and some test doubles.

For the common cases where you do not need the complexity of the heavyweight libraries.

interface PostRequestSender {

	/**
	 * @param string $url
	 * @param array<string, mixed> $fields
	 */
	public function post( string $url, array $fields ): PostResponse;

}

Usage

$response = $requestSender->post( 'https://example.com', [ 'foo' => 'bar', 'baz' => 42 ] );
echo $response->body;
echo $response->statusCode;

Included implementations

Adapters

  • GuzzlePostRequestSender Adapter for Guzzle

Decorators

  • LoggingPostRequestSender Takes a Psr\Log\LoggerInterface
  • SpyPostRequestSender Test double that records calls

Test doubles

  • SpyPostRequestSender Test double that records calls
  • StubPostRequestSender Test double that returns a response provided in the constructor

Release notes

2.0.0 (2022-02-03)

  • Ditched ResponseInterface in favor of a new simple value object PostResponse

1.0.1 (2022-02-02)

  • Fixed behavior of TestResponse::getBody

1.0.0 (2022-01-30)

Initial release with

  • PostRequestSender interface
  • SpyPostRequestSender test double (and PostRequest value object)
  • StubPostRequestSender test double
  • GuzzlePostRequestSender implementation
  • LoggingPostRequestSender decorator
  • TestResponse helper implementation or PSR7 ResponseInterface