Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Pact Specification v4 #318

Closed
judimator opened this issue Jul 10, 2023 · 16 comments
Closed

Support Pact Specification v4 #318

judimator opened this issue Jul 10, 2023 · 16 comments

Comments

@judimator
Copy link

Hi there,

I am wondering if PHP library is going to support Pact Specification v4 soon?

If it is no, I guess, changing implementation of PhpPact\Consumer\Model\Interaction will help me to send, say, params for providerState (see Example 1):

Example 1:

{
  "providerStates": [
    {
      "name": "an alligator with the given name exists",
      "params": {"name" : "Mary"}
    }, {
      "name": "the user is logged in",
      "params" : { "username" : "Fred"}
    }
  ]
}

Thank you!

@mefellows
Copy link
Member

@tienvx is currently working on a migration to the new Rust FFI, which would support this. We should perhaps pin an issue that is being worked on to raise visibility. What do you think @YOU54F ?

In the meantime, that PR would probably work if you were open to creating one (I know somebody did something similar for Pact JS a few years ago).

@judimator
Copy link
Author

@mefellows could you tell me what branch(PR) I can use then (there a dozen of them as I see https://github.com/pact-foundation/pact-php/pulls)

@mefellows
Copy link
Member

mefellows commented Jul 10, 2023

I don't know the branch (hence why I @ed them). But if you just want parameters, you'll be waiting a while (as the aforementioned work is quite a large amount of change). I'd suggest a PR to the current mainline.

You'd need to test that it actually does anything though, I might be getting my PRs mixed up. I looked at the Pact JS PRs and couldn't find the one I thought.

@judimator
Copy link
Author

@tienvx @YOU54F Any thoughts?

@YOU54F
Copy link
Member

YOU54F commented Jul 10, 2023

Hey,

we will be using the ffi branch as per #313 (comment)

@tienvx has split out the PR's at the moment, each one is numbered and builds on the last, #280 would be a good place to start

@YOU54F
Copy link
Member

YOU54F commented Jul 10, 2023

We should perhaps pin an issue that is being worked on to raise visibility. What do you think @YOU54F ?

We have this

#262

which could do with updating, agree its worth pinning and as part of the ffi maintainers guide getting the checklist to completion :)

@mefellows
Copy link
Member

Ah I did see that. I'll pin that one for now for visibility, but I realise that there is not much visibility on this repo that there is a mountain of work going on under the hood. We could also perhaps flesh this project board out.

@YOU54F
Copy link
Member

YOU54F commented Jul 24, 2023

Current status is listed in #262 (comment)

May be worth closing this down to avoid duplication, but TL;DR is you can test this out today in your projects, by checking out the instructions in the above pinned issue 👍🏾

@mefellows mefellows added duplicate Indicates similar issues, pull requests, or discussions and removed duplicate Indicates similar issues, pull requests, or discussions labels Jul 24, 2023
@mefellows
Copy link
Member

I think technically you could make this work with the current version, but it would need somebody to spike/test it (ideally the OP). The ideal solution of course is the proper support for V3/V4 pacts in the referenced issue.

@YOU54F
Copy link
Member

YOU54F commented Jul 28, 2023

We've just released an alpha package today with some instructions - HTH

https://github.com/pact-foundation/pact-php/releases/tag/10.0.0-alpha1

@judimator
Copy link
Author

@YOU54F So I can not use common php FFI but use yours pact_ffi ?

@judimator
Copy link
Author

I am installing FFI like

RUN apk add --no-cache --virtual .persistent-deps libffi-dev \
    && docker-php-ext-configure ffi --with-ffi \
    && docker-php-ext-install ffi

RUN echo "ffi.enable=true" >> /usr/local/etc/php/conf.d/docker-php-ext-ffi.ini

But as I see header file contatns string C++ like string #include which are not supported by FFI(see https://www.php.net/manual/en/ffi.cdef.php#refsect1-ffi.cdef-parameters)

@YOU54F
Copy link
Member

YOU54F commented Sep 18, 2023

alpine isn't supported, with the v10.x branch, I am afraid. If you use a debian slim image, things will be smoother

You need the ffi extension, pact-php will take care of loading the library for you.

See https://github.com/pact-foundation/pact-php/blob/d87ffec34fecb32932e51fc5a95ad0baaf31a9dc/.cirrus.yml#L30C1-L34C35

@YOU54F
Copy link
Member

YOU54F commented Sep 19, 2023

just another pointer in code, this is where pact php reads in the header file, and shared lib

https://github.com/pact-foundation/pact-php/blob/ffi/src/PhpPact/Standalone/Installer/Model/Scripts.php

and this is where phps ffi method is called

https://github.com/pact-foundation/pact-php/blob/ffi/src/PhpPact/FFI/Client.php

@judimator
Copy link
Author

Thanks a lot! @YOU54F

@YOU54F
Copy link
Member

YOU54F commented May 16, 2024

V4 available in v10.x alpha, and mainlined to master branch

See compat table

https://github.com/pact-foundation/pact-php?tab=readme-ov-file#compatibility

fyi alpine support is coming :) #613

@YOU54F YOU54F closed this as completed May 16, 2024
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

No branches or pull requests

3 participants