Skip to content

Commit

Permalink
Swap laminas/laminas-diactoros for guzzlehttp/psr7
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Sep 4, 2024
1 parent a758017 commit 6c7589a
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 100 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"amphp/phpunit-util": "^3",
"amphp/php-cs-fixer-config": "^2",
"phpunit/phpunit": "^9",
"laminas/laminas-diactoros": "^2.3",
"guzzlehttp/psr7": "^2",
"psalm/phar": "^5"
},
"provide": {
Expand Down
9 changes: 4 additions & 5 deletions examples/psr-with-amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
use Amp\Http\Client\HttpClientBuilder;
use Amp\Http\Client\Psr7\PsrAdapter;
use Amp\Http\Client\Psr7\PsrHttpClient;
use Laminas\Diactoros\RequestFactory;
use Laminas\Diactoros\ResponseFactory;
use GuzzleHttp\Psr7\HttpFactory;

require __DIR__ . '/../vendor/autoload.php';

$requestFactory = new RequestFactory;
$psrHttpFactory = new HttpFactory();

$psrHttpClient = new PsrHttpClient(
HttpClientBuilder::buildDefault(),
new PsrAdapter($requestFactory, new ResponseFactory)
new PsrAdapter($psrHttpFactory, $psrHttpFactory)
);

$psrResponse = $psrHttpClient->sendRequest($requestFactory->createRequest('GET', 'https://api.github.com/'));
$psrResponse = $psrHttpClient->sendRequest($psrHttpFactory->createRequest('GET', 'https://api.github.com/'));

print $psrResponse->getBody();
4 changes: 2 additions & 2 deletions test/Internal/PsrInputStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Amp\Http\Client\Psr7\Internal;

use Laminas\Diactoros\StreamFactory;
use GuzzleHttp\Psr7\HttpFactory;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\StreamInterface;

Expand Down Expand Up @@ -87,7 +87,7 @@ public function testReadReturnsMatchingDataFromStream(
string $firstChunk,
string $secondChunk
): void {
$stream = (new StreamFactory())->createStream($sourceData);
$stream = (new HttpFactory())->createStream($sourceData);

$inputStream = new PsrInputStream($stream, $chunkSize);

Expand Down
4 changes: 2 additions & 2 deletions test/Internal/PsrStreamBodyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Amp\Http\Client\Psr7\Internal;

use Laminas\Diactoros\StreamFactory;
use GuzzleHttp\Psr7\HttpFactory;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\StreamInterface;
use function Amp\ByteStream\buffer;
Expand Down Expand Up @@ -44,7 +44,7 @@ public function testContentTypeIsNull(): void

public function testCreateBodyStreamResultReadsFromOriginalStream(): void
{
$stream = (new StreamFactory())->createStream('body_content');
$stream = (new HttpFactory())->createStream('body_content');
$body = new PsrStreamBody($stream);

self::assertSame('body_content', buffer($body->getContent()));
Expand Down
Loading

0 comments on commit 6c7589a

Please sign in to comment.