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

PHP bindings #1844

Closed
vanillajonathan opened this issue Feb 15, 2023 · 4 comments · Fixed by #1860
Closed

PHP bindings #1844

vanillajonathan opened this issue Feb 15, 2023 · 4 comments · Fixed by #1860
Labels

Comments

@vanillajonathan
Copy link
Collaborator

vanillajonathan commented Feb 15, 2023

PRQL should have bindings for PHP. PHP have a FFI, which of particular interest is the FFI::cdef function.

@max-sixty
Copy link
Member

Thanks @vanillajonathan . If you want to take a swing at creating these and adding them to the repo, with tests, that would be very valuable.

The issues are still helpful on the margin though.

@vanillajonathan
Copy link
Collaborator Author

I got it to work, it uses the libprql_lib library which it loads using the PHP FFI extension. So for this to work the PHP FFI extension needs to be enabled. It searches for a file called libprql_lib.so in same directory as the PHP script.

I've seen some bindings offer the compile function, but the C library only offers:

int to_sql(char *prql_query, char *sql_query);
int to_json(char *prql_query, char *json_query);

By the way, the prql-lib contains no C header file.

This PHP script contains a to_sql and a to_json function which works. It also contains the compile function which does not work.

@max-sixty
Copy link
Member

I've seen some bindings offer the compile function, but the C library only offers:

I think this is because the prql-lib was built on an older version of PRQL. It would be quite welcome to update prql-lib and add some tests for it, so it stays current.

It was originally written as a quick piece of code.

@vanillajonathan
Copy link
Collaborator Author

I would like to merge this, I created pull request #1860.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants