psr-7

PSR-7 “attributes” on Response object

≡放荡痞女 提交于 2020-01-02 21:19:29
问题 I'm developing using PSR-7 (with Zend Expressive). I figured out the method ServerRequestInterface::withAttribute() and I was wondering why the object Response doesn't have one. I'd like to pass metadata through middlewares after processing, on "response side". Is there somehow to pass "attributes" on Response for post-processing? What's is the best way, following the architecture guidelines, to achieve that? 回答1: The PSR-7 specification defines attributes only for server requests. They are

How to disable URL encoding in Guzzle 6

匆匆过客 提交于 2019-12-25 03:09:05
问题 I'm working with pipedrive API and I want to make such a request: GET https://api.pipedrive.com/v1/deals(id,title,value,currency)?api_token=YOUR_API_TOKEN It works fine eg. when I do the request with a browser, but when I send the request with Guzzle I get response 501. I assume that it gets encoded in a way that's not recognized by Pipedrive API. Is there a way to disable URL encoding in Guzzle 6? 回答1: Seems like this is a bug and I'm not the only one facing this issue: https://github.com

php error at runtime Interface 'Psr\Container\ContainerInterface' not found

走远了吗. 提交于 2019-12-24 18:40:07
问题 I recently uploaded a new dependency to a PHP app I am working on and I am now continually getting the following error in Postman Fatal error : Interface 'Psr\Container\ContainerInterface' not found in /var/www/html/api/vendor/container-interop/container-interop/src/Interop/Container/ContainerInterface.php on line 13 I have updated composer as well as a multitude of other things and still cannot seem to pinpoint the issue. (Also not sure if it means the error is with the index.php file or the

Slim framework and email template rendering issue with PHPmailer

泄露秘密 提交于 2019-12-11 07:33:20
问题 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 templates and then pass some variables into it, render it and send it. It all works well except for one part - rendered output also has rendered header info. This is how my code looks like, simplified of course // Store variables in an array $email_content

PSR-7 “attributes” on Response object

隐身守侯 提交于 2019-12-06 19:54:28
I'm developing using PSR-7 (with Zend Expressive). I figured out the method ServerRequestInterface::withAttribute() and I was wondering why the object Response doesn't have one. I'd like to pass metadata through middlewares after processing, on "response side". Is there somehow to pass "attributes" on Response for post-processing? What's is the best way, following the architecture guidelines, to achieve that? The PSR-7 specification defines attributes only for server requests. They are mainly use to store metadata deduced from the incoming request so that they could be used later when you

Psr7 Http Message, why immutable?

梦想与她 提交于 2019-12-05 13:51:51
问题 I am looking at the PSR-7 interfaces and thinking of a way on how to implement them. I've also been reading this blog post. Apparently the objects that implement the PSR-7 interfaces must be immutable. So if I implement the withProtocolVersion method from MessageInterface then it would look something like this: public function withProtocolVersion($version) { if ( $this->protocol === $version ) { return $this; } $new = clone $this; $new->protocol = $version; return $new; } My question really

Slim 3 - How to add 404 Template?

与世无争的帅哥 提交于 2019-12-04 13:14:18
问题 In Slim 2, I can over write the default 404 page easily, // @ref: http://help.slimframework.com/discussions/problems/4400-templatespath-doesnt-change $app->notFound(function () use ($app) { $view = $app->view(); $view->setTemplatesDirectory('./public/template/'); $app->render('404.html'); }); But in Slim 3, // ref: http://www.slimframework.com/docs/handlers/not-found.html //Override the default Not Found Handler $container['notFoundHandler'] = function ($c) { return function ($request,

Psr7 Http Message, why immutable?

回眸只為那壹抹淺笑 提交于 2019-12-04 00:40:56
I am looking at the PSR-7 interfaces and thinking of a way on how to implement them. I've also been reading this blog post . Apparently the objects that implement the PSR-7 interfaces must be immutable. So if I implement the withProtocolVersion method from MessageInterface then it would look something like this: public function withProtocolVersion($version) { if ( $this->protocol === $version ) { return $this; } $new = clone $this; $new->protocol = $version; return $new; } My question really is, why immutable? Why not simply do a return $this; ? It's not that I'm concerned about the amount of

How to read the response effective URL in Guzzle ~6.0

£可爱£侵袭症+ 提交于 2019-12-03 04:07:00
问题 I've been searching for about 2 hours and I can't figure it out how to read the final response uri. In previous versions of PHP Guzzle you just call $response->getEffectiveUrl() and you get it. I expected to have something similar in the new version so the final code looks like this: $response = $httpClient->post('http://service.com/login', [ 'form_params' => [ 'user' => $user, 'padss' => $pass, ] ]); $url = $response->getEffectiveUrl(); But in the latest version $response is now a GuzzleHttp

How to read the response effective URL in Guzzle ~6.0

不想你离开。 提交于 2019-12-02 19:04:23
I've been searching for about 2 hours and I can't figure it out how to read the final response uri. In previous versions of PHP Guzzle you just call $response->getEffectiveUrl() and you get it. I expected to have something similar in the new version so the final code looks like this: $response = $httpClient->post('http://service.com/login', [ 'form_params' => [ 'user' => $user, 'padss' => $pass, ] ]); $url = $response->getEffectiveUrl(); But in the latest version $response is now a GuzzleHttp\Psr7\Response and there is no method which allow me to retrieve the uri. I read about the redirects