Skip to content

Conversation

@erunion
Copy link
Contributor

@erunion erunion commented Apr 29, 2022

This is a replay of the work I did in #228 just against the new TS rewrite.

This finishes up the work that @robertoarruda started in #140 to add a new PHP target for Guzzle.

Differences between their PR and this one:

  • Removed some unused/unimplemented options.
  • Fixed up all unit tests.
  • Manually tested every Guzzle-generated snippet to ensure that it runs.
    • Some tweaks had to be made to multipart and cookie handling as a result of this.

Resolves #132 (and also #140).

changelog(New): adds PHP client for Guzzle

Copy link
Contributor

@dimitropoulos dimitropoulos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm totally cool with this. I'm not a PHP dev, but I'm assuming you are (enough, anyway, to write this).

Copy link
Contributor

@dimitropoulos dimitropoulos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot_20220513_154150

oh shoot, now we need a new fixture since #258 merged. would you mind taking a look? I added it for you in 7203a16:

<?php

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://mockbin.com/har');

echo $response->getBody();

but it doesn't seem complete because it doesn't say anything about multipart

@erunion
Copy link
Contributor Author

erunion commented May 19, 2022

@dimitropoulos This is good for review again:

Screen Shot 2022-05-19 at 11 22 27 AM

@erunion
Copy link
Contributor Author

erunion commented May 19, 2022

I'm totally cool with this. I'm not a PHP dev, but I'm assuming you are (enough, anyway, to write this).

I am, or at least used to be a PHP dev, but we have this new target fully covered by code coverage within an integration suite I built in our fork. It works I swear!

@dimitropoulos
Copy link
Contributor

looks great

@dimitropoulos dimitropoulos merged commit 62d158d into Kong:master May 19, 2022
@erunion erunion deleted the feat/guzzle-target branch May 20, 2022 03:05
erunion referenced this pull request in readmeio/httpsnippet Jul 16, 2022
* Total Overhaul (but with all the same fixtures!) (#248)

see Kong#248 and the commits therein for more context.  Essentially:
- the original client fixtures were unchanged, which hopefully means the 
- all source code is now in strict mode TypeScript
- tests are now all in jest
- the file structure was reorganized so that everything for a particular client is in one place
- the CLI is updated and now using yargs
- all dependencies were updated and some (i.e. `format.utils`) were able to be removed entirely
- more work left to do (including CI with GitHub Actions, for example), but this is a start

* fix: case where if `postData.params` is missing some targets crash (#258)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: compatibility issues on node 14 with `Object.hasOwn()` (#252)

* fix: typo in the httpie `style` option not being correctly applied (#254)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: axios targets not sending `x-www-form-urlencoded` properly (#255)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* feat: addition of a PHP target for Guzzle (#253)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* Add Github Build Workflow (#250) (#251)

* Add Github Build Workflow (#250)

* Edit job name

* Replace install with ci on GH workflow

* Add matrix with major node versions (14, 16, 18)

* Disable fail-fast

* Remove node v14 from build GH action

* feat: native upload support in python `requests` snippets (#259)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: `multipart/form-data` header issues with node/js fetch targets (#257)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: headers not being properly applied to R httr snippets (#263)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* Fix build workflow dispatch rules (#265)

* Chore: Remove travis links (#266)

* Remove travis links

* Update README.md

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* chore: fixing eslint issues

* fix: updating test snapshots

* fix: getting the stock target tests all passing

* fix: broken snapshots

* fix: adding missing test coverage for addTarget and addTargetClient

* fix: build issues

* feat: getting the integration tests suite running again

* fix: issues with the docker setup

* fix: removing unnecessary tests

* fix: running docker tests

* fix: typo

* fix: reverting some query param changes to node axios + request

* fix: docker issues

* fix: cleaning up the integration suite config system

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
Co-authored-by: Filipe Freire <livrofubia@gmail.com>
erunion referenced this pull request in readmeio/httpsnippet Jul 17, 2022
* Total Overhaul (but with all the same fixtures!) (#248)

see Kong#248 and the commits therein for more context.  Essentially:
- the original client fixtures were unchanged, which hopefully means the 
- all source code is now in strict mode TypeScript
- tests are now all in jest
- the file structure was reorganized so that everything for a particular client is in one place
- the CLI is updated and now using yargs
- all dependencies were updated and some (i.e. `format.utils`) were able to be removed entirely
- more work left to do (including CI with GitHub Actions, for example), but this is a start

* fix: case where if `postData.params` is missing some targets crash (#258)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: compatibility issues on node 14 with `Object.hasOwn()` (#252)

* fix: typo in the httpie `style` option not being correctly applied (#254)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: axios targets not sending `x-www-form-urlencoded` properly (#255)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* feat: addition of a PHP target for Guzzle (#253)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* Add Github Build Workflow (#250) (#251)

* Add Github Build Workflow (#250)

* Edit job name

* Replace install with ci on GH workflow

* Add matrix with major node versions (14, 16, 18)

* Disable fail-fast

* Remove node v14 from build GH action

* feat: native upload support in python `requests` snippets (#259)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: `multipart/form-data` header issues with node/js fetch targets (#257)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: headers not being properly applied to R httr snippets (#263)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* Fix build workflow dispatch rules (#265)

* Chore: Remove travis links (#266)

* Remove travis links

* Update README.md

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: issue where query strings in R wouldn't be properly concatenated (#269)

* fix: issue where query strings in R wouldn't be properly concatenated

* adds (and respects) indent options to httr, plus double looping fix

now, indent is respected, and also avoiding running Object.keys twice per run since we can just run it once with .entries

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* add header namesspace to prevent header errors (#247)

* add header namesspace to prevent header errors

* update fixtures

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: stop implicitly coercing warning in Swift snippet generator (#195)

* swift/nsurlsession adds `as Any` to print for error

* adds OVERWRITE_EVERYTHING to ease fixture snapshot resetting

* updates fixtures

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: clj-http handling of literal null JSON bodies (#283)

Co-authored-by: Sergey Zakharchenko <szakharchenko@digital-loggers.com>

* fix: prevent crash in Swift/Objc with checking length of input body post params (#192)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: cUrl target should encode x-www-form-urlencoded post data params (#198)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: linting issues

* fix: reverting package-lock changes

* chore: removing unused fixtures

* fix: removing unnecessary typing

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
Co-authored-by: Filipe Freire <livrofubia@gmail.com>
Co-authored-by: Davis Martin <davis.martin@procore.com>
Co-authored-by: iraj taghlidi <785830+irajtaghlidi@users.noreply.github.com>
Co-authored-by: Sergey Zakharchenko <szakharchenko@digital-loggers.com>
Co-authored-by: Julien Giovaresco <dev@giovaresco.fr>
erunion referenced this pull request in readmeio/httpsnippet Jun 16, 2023
* Total Overhaul (but with all the same fixtures!) (#248)

see Kong#248 and the commits therein for more context.  Essentially:
- the original client fixtures were unchanged, which hopefully means the 
- all source code is now in strict mode TypeScript
- tests are now all in jest
- the file structure was reorganized so that everything for a particular client is in one place
- the CLI is updated and now using yargs
- all dependencies were updated and some (i.e. `format.utils`) were able to be removed entirely
- more work left to do (including CI with GitHub Actions, for example), but this is a start

* fix: case where if `postData.params` is missing some targets crash (#258)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: compatibility issues on node 14 with `Object.hasOwn()` (#252)

* fix: typo in the httpie `style` option not being correctly applied (#254)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: axios targets not sending `x-www-form-urlencoded` properly (#255)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* feat: addition of a PHP target for Guzzle (#253)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* Add Github Build Workflow (#250) (#251)

* Add Github Build Workflow (#250)

* Edit job name

* Replace install with ci on GH workflow

* Add matrix with major node versions (14, 16, 18)

* Disable fail-fast

* Remove node v14 from build GH action

* feat: native upload support in python `requests` snippets (#259)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: `multipart/form-data` header issues with node/js fetch targets (#257)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: headers not being properly applied to R httr snippets (#263)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* Fix build workflow dispatch rules (#265)

* Chore: Remove travis links (#266)

* Remove travis links

* Update README.md

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: issue where query strings in R wouldn't be properly concatenated (#269)

* fix: issue where query strings in R wouldn't be properly concatenated

* adds (and respects) indent options to httr, plus double looping fix

now, indent is respected, and also avoiding running Object.keys twice per run since we can just run it once with .entries

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* add header namesspace to prevent header errors (#247)

* add header namesspace to prevent header errors

* update fixtures

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: stop implicitly coercing warning in Swift snippet generator (#195)

* swift/nsurlsession adds `as Any` to print for error

* adds OVERWRITE_EVERYTHING to ease fixture snapshot resetting

* updates fixtures

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: clj-http handling of literal null JSON bodies (#283)

Co-authored-by: Sergey Zakharchenko <szakharchenko@digital-loggers.com>

* fix: prevent crash in Swift/Objc with checking length of input body post params (#192)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* fix: cUrl target should encode x-www-form-urlencoded post data params (#198)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* feat: Add support for insecureSkipVerify (#285)

* go/native: adds insecureSkipVerify

* node/native: adds insecureSkipVerify

* python/python3: adds insecureSkipVerify

* ruby/native: adds insecureSkipVerify

* shell/curl: adds insecureSkipVerify

Co-authored-by: Tim Perry <pimterry@gmail.com>

* feat: implementing cleaner handling of JSON in cURL snippets (#256)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* chore: minor cleanup (#286)

* feat: use curl's --compressed option for requests that accept it (#287)

* feat: make Python snippets simpler, clearer & more consistent (#288)

Co-authored-by: Tim Perry <pimterry@gmail.com>

* feat: change the default response code for Python Requests (#181)

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* feat: PHP JSON body encoding (#291)

* php/curl: use json_encode for CURLOPT_POSTFIELDS

* php/http1: use json_encode when body is JSON

* php/http2: use json_encode when body is JSON

Co-authored-by: Andrii Kostenko <andrey@kostenko.name>

* Async/Await (top level) support in JavaScript snippets (#292)

* Exclude package.json from build to fix output paths (#294)

* Exclude package.json from build to fix output paths

* keeps bin pointing at cli output

* makes rootDir explicit

* removes unused cli build scripts

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>

* Fix crash when building nsurlsession snippets for empty params (#295)

* removes `require 'openssl'` from ruby target (no longer needed) (#296)

* Escape quotes in headers correctly in all languages (#289)

* updates README (#299)

Co-authored-by: Filipe Freire <livrofubia@gmail.com>

* ioutil -> io (deprecated) (#305)

* chore: undoing unwanted changes

* chore: revert more unwanted changes

* chore: reverting more unwanted changes

* fix: fixing broken test snapshots and libcurl not escaping

* fix: a bunch of broken tests

* fix: removing dead code

* fix: remove support for `insecureSkipVerify` as we dont need or want it

* fix: removing top-level await changes for axios

* fix: revert top-level await changes for js:fetch

* fix: remove some problematic changes to `node:request`

* fix: retaining line trimming in powershell snippets

* fix: bug in php snippets where booleans were casted to null

* fix: revert problematic changes to python:requests

* fix: revert more unwanted changes

* chore: temporarily skipping the integration suite

* fix: broken snapshot

* fix: disabling the integration suite from being run without inside docker

* fix: integration suite

* fix: integration suite

---------

Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com>
Co-authored-by: Filipe Freire <livrofubia@gmail.com>
Co-authored-by: Davis Martin <davis.martin@procore.com>
Co-authored-by: iraj taghlidi <785830+irajtaghlidi@users.noreply.github.com>
Co-authored-by: Sergey Zakharchenko <szakharchenko@digital-loggers.com>
Co-authored-by: Julien Giovaresco <dev@giovaresco.fr>
Co-authored-by: Tim Perry <pimterry@gmail.com>
Co-authored-by: Andrii Kostenko <andrey@kostenko.name>
Co-authored-by: Tim Perry <1526883+pimterry@users.noreply.github.com>
Co-authored-by: Alexander Weber <aw@voidpointergroup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHP Guzzle generator

2 participants