Skip to content

Commit

Permalink
Update upgrade guide
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Mar 26, 2018
1 parent 513e0f7 commit eb24fe0
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
The primary difference is the HTTP Client. We are now using HTTPlug (http://httplug.io/) but rely on our own interface.

### Breaking
- Change typehint from Guzzle ClientInterface to `Omnipay\Common\Http\Client`
- `$client->get('..')`/`$client->post('..')` will send the request directly, no longer need to call `->send()`.
- Instead of `$client->createRequest(..)->send()`, you should call `$client->sendRequest($client->createRequest(..))`.
- When sending an AJAX body, convert the body to a string with `json_encode`.
- Change typehint from Guzzle ClientInterface to `Omnipay\Common\Http\ClientInterface`
- `$client->get('..')`/`$client->post('..')` etc are removed, you can call `$client->request('GET', '')`.
- No need to call `$request->send()`, requests are sent directly.
- Instead of `$client->createRequest(..)` you can create+send the request directly with `$client->request(..)`.
- When sending a JSON body, convert the body to a string with `json_encode()` and set the correct Content-Type.
- The response is a PSR-7 Response object. You can call `$response->getBody()->getContents()` to get the body as string.
- `$response->json()` and `$response->xml()` are gone, but `Omnipay\Common\Http\ResponseParser::json($response)`
and `Omnipay\Common\Http\ResponseParser::xml($response)` can be used instead.
- `$response->json()` and `$response->xml()` are gone, but you can implement the logic directly.
- An HTTP Client is no longer added by default by `omnipay/common`, but `omnipay/omnipay` will add Guzzle.
Gateways should not rely on Guzzle or other clients directly.

### Deprecated
- `$body` should be a string (eg. `http_build_query($data)` or `json_encode($data)` instead of just `$data`).
- The `$headers` parameters should be an `array` (not `null`, but can be empty)
- `$body` should be a string (eg. `http_build_query($data)` or `json_encode($data)` instead of just $data.

Note: Prior to stable release, the goal is to migrate to PSR-18, once completed.
This will not change the gateway implementations.

0 comments on commit eb24fe0

Please sign in to comment.