Questions tagged [psr-7]

PSR-7 is the FIG standard for HTTP messages in PHP. It provides abstractions of HTTP messages and their components and defines a consistent set of interfaces to work with them.

The purpose of PSR-7 is to provide PHP with a set of common interfaces for HTTP messages as described in RFC 7230 and RFC 7231, and URIs as described in RFC 3986 (in the context of HTTP messages).

All HTTP messages consist of the HTTP protocol version being used, headers, and a message body. A Request builds on the message to include the HTTP method used to make the request, and the URI to which the request is made. A Response includes the HTTP status code and reason phrase.

In PHP, HTTP messages are used in two contexts:

  • To send an HTTP request, via the ext/curl extension, PHP's native stream layer, etc., and process the received HTTP response. In other words, HTTP messages are used when using PHP as an HTTP client.
  • To process an incoming HTTP request to the server, and return an HTTP response to the client making the request. PHP can use HTTP messages when used as a server-side application to fulfil HTTP requests.
94 questions
1
vote
1 answer

$response->getBody()->getContents() returning empty string

I have the code below: getBody()->getContents(); echo $response->getBody(); I'm passing the body directly in the constructor. I'm trying…
Eleandro Duzentos
  • 1,370
  • 18
  • 36
1
vote
0 answers

Emiting a PSR-7 response from Symfony3

I am attempting to emit and receive PSR-7 style responses in Symfony 3.2.6 I have been attempting to follow the original post from dunglas on the subject which makes it seem rather simple. using-psr-7-in-symfony I have…
fafnirbcrow
  • 270
  • 3
  • 8
1
vote
1 answer

Guzzle 6 - getting the effective url

I have just upgraded from guzzle 3 to guzzle 6 Now i have some code here.. $request = $this->_client->get($url); $response = $request->send(); $url = $response->getInfo('url'); return $url; After updating to guzzle…
Matthew Harris
  • 51
  • 3
  • 10
1
vote
0 answers

using Dice - Dependency Injector with Zend Diactoros and Fast Route

I'm using Dice(a nice Dependency Injector) for a small project. I am also using the PSR7 Zend Diactoros for requests and nikic fast route. I got Dice working for Twig, DB and all the rest of my classes using the examples from docs, but I am unable…
user2137406
  • 41
  • 1
  • 4
1
vote
1 answer

Slim framework and email template rendering issue with PHPmailer

I am using Slim v3 php framework and have integrated PHPMailer to send mails. I don't use any template engine like Twig, but I rather use plain PHP. My idea is to make a HTML5 template for emails in a separate file, similar to regular page…
Vladimir Jovanović
  • 3,288
  • 1
  • 20
  • 27
1
vote
1 answer

Image only loading some of the time when streamed(?) to client

I've been writing a web app for some time now, and I've been running into some issues with serving images. My code pulls file data from the server, using file_get_contents, and uses Slim's Request object's write method to output the contents of the…
Bytewave
  • 597
  • 1
  • 8
  • 20
1
vote
1 answer

Cannot echo guzzle xml response GuzzleHttp\Psr7\Response::xml()

Using laravel 5.2 I tried the folowing code: $xml = " myuserid myloginkey mytransactionid "; $request = $client->request('POST',…
davejal
  • 6,009
  • 10
  • 39
  • 82
1
vote
2 answers

Passing data between middelware

I use zend-expressive and i would like to pass data from one middelware to another. e.g. in config/routes.php I've [ 'name' => 'v1.item.list', 'path' => '/item', 'allowed_methods' => ['GET'], 'middleware' => [ …
quentino
  • 1,101
  • 1
  • 10
  • 25
1
vote
0 answers

Add value in middleware SlimV3

Im new in SLimV3, And I Want to use the middleWare to create Json Output. My code is: Controller: public function __invoke(Request $request, Response $response, $args) { .... $out['message'] = "ok"; $out['code'] = 0; …
monkeyUser
  • 4,301
  • 7
  • 46
  • 95
1
vote
1 answer

slim framework PSR not recognising custom header

Following is the code I am using.
Jacob Nelson
  • 2,370
  • 23
  • 35
1
vote
1 answer

Converting Request from CURL to PHP's Guzzle to access WHMCS API

I'm attempting to learn the latest version of Guzzle (6.2) and convert my cURL requests to the WHMCS API. Using the example code from: http://docs.whmcs.com/API:JSON_Sample_Code // The fully qualified URL to your WHMCS installation root…
Muzzstick
  • 304
  • 1
  • 2
  • 9
1
vote
2 answers

Zend PSR7 does not work on Lumen?

Zend PSR7 does not seem to work on Lumen: use Psr\Http\Message\ServerRequestInterface; use Zend\Diactoros\Response; // PSR 7 $app->bind('Psr\Http\Message\ServerRequestInterface', function ($app) { return (new…
Run
  • 54,938
  • 169
  • 450
  • 748
0
votes
1 answer

TYPO3 sitepackage: How to access PSR-7 Request Object or TYPO3_REQUEST in TCA/Overrides?

I’m in TYPO3 11.5. In my sitepackage extension I need to access the TYPO3 request object in either Configuration/TCA/Overrides/tt_content.php or a custom class method. But I don’t know how to instantiate the PSR-7 request object nor is the old style…
clive beckett
  • 152
  • 16
0
votes
0 answers

Asynchronous requests using proxy with Guzzle 7

Im trying create a PHP script that uses proxy and asynchronous requests with Guzzle but Im not reaching the success. On the Guzzle 7 docs, we can see this example below: use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; use…
John
  • 1
  • 1
0
votes
1 answer

Convert curl command to Guzzle psr7 http

I need to convert this cURL command to php: curl -X POST https://google.com \ -H 'custom_id: 1234' \ --form 'file=@"/Desktop/image.jpg"' \ --form 'options_json="{\"rm_spaces\": true}"' I have tried something like this:
dosad
  • 151
  • 7