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

build: Add PHP binding #1860

Merged
merged 46 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
987142f
Update README.md
vanillajonathan Feb 17, 2023
fad594d
Create php.md
vanillajonathan Feb 17, 2023
c24435d
Create .gitignore
vanillajonathan Feb 17, 2023
4378fb7
Add files via upload
vanillajonathan Feb 17, 2023
e88275f
Update composer.json
vanillajonathan Feb 17, 2023
90facac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 17, 2023
358adb7
Update composer.json
vanillajonathan Feb 17, 2023
60dd7af
Update Compiler.php
vanillajonathan Feb 17, 2023
acb0686
Update prql-php/.gitignore
vanillajonathan Feb 17, 2023
ef37369
Merge branch 'main' into patch-1
vanillajonathan Feb 17, 2023
cff81ac
Add composer lock file
vanillajonathan Feb 17, 2023
a44ef7a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 17, 2023
68feb33
Merge branch 'PRQL:main' into patch-1
vanillajonathan Feb 17, 2023
c39b948
Create test-php.yaml
vanillajonathan Feb 17, 2023
604ccf3
Update test-php.yaml
vanillajonathan Feb 17, 2023
c381fea
Update test-php.yaml
vanillajonathan Feb 17, 2023
f554472
Update composer.json
vanillajonathan Feb 17, 2023
e7790b1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 17, 2023
6fed448
Update composer.json
vanillajonathan Feb 17, 2023
e9e9b0c
Update test-php.yaml
vanillajonathan Feb 17, 2023
035283d
Update test-php.yaml
vanillajonathan Feb 17, 2023
7ffb9e9
Update test-php.yaml
vanillajonathan Feb 17, 2023
5560ef4
Update test-php.yaml
vanillajonathan Feb 17, 2023
272facb
Update test-php.yaml
vanillajonathan Feb 17, 2023
2f6a8a1
Uncomment unit tests
vanillajonathan Feb 17, 2023
8ed7aa2
Pass test dir as args
vanillajonathan Feb 18, 2023
715955f
Bootstrap the autoloader
vanillajonathan Feb 18, 2023
f112241
Build library and copy library file
vanillajonathan Feb 18, 2023
15f7fd8
Update test-php.yaml
vanillajonathan Feb 18, 2023
d2ce386
Update test-php.yaml
vanillajonathan Feb 18, 2023
4b0470b
Update test-php.yaml
vanillajonathan Feb 19, 2023
e2878cd
Update test-php.yaml
vanillajonathan Feb 19, 2023
86a34b0
Update test-php.yaml
vanillajonathan Feb 19, 2023
dd23e2a
Update test-php.yaml
vanillajonathan Feb 19, 2023
44f77cb
Update test-php.yaml
vanillajonathan Feb 19, 2023
3db2a06
Add more unit tests
vanillajonathan Feb 19, 2023
8813bb2
Update CompilerTest.php
vanillajonathan Feb 19, 2023
5637195
Update test-php.yaml
vanillajonathan Feb 19, 2023
1386d7a
Update CompilerTest.php
vanillajonathan Feb 20, 2023
d436e7d
Update test-php.yaml
vanillajonathan Feb 20, 2023
cea7839
Merge branch 'main' into patch-1
max-sixty Feb 20, 2023
d9732dc
Add test-php
vanillajonathan Feb 20, 2023
3d0bdd1
Add concurrency thing
vanillajonathan Feb 20, 2023
385dd5c
Remove php-actions/phpunit
vanillajonathan Feb 20, 2023
47e925f
Update .github/workflows/test-php.yaml
max-sixty Feb 20, 2023
45c952c
max-sixty Feb 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
os: ${{ matrix.os }}
target_option: ${{ matrix.target_option }}

test-php:
uses: ./.github/workflows/test-php.yaml

test-python:
uses: ./.github/workflows/test-python.yaml

Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/test-php.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: test-php

on:
push:
branches:
- main
vanillajonathan marked this conversation as resolved.
Show resolved Hide resolved
max-sixty marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
paths:
- "prql-php/**"
- ".github/workflows/test-php.yaml"
workflow_call:

vanillajonathan marked this conversation as resolved.
Show resolved Hide resolved
concurrency:
# See notes in `pull-request.yaml`
group: ${{ github.workflow }}-${{ github.ref }}-php
cancel-in-progress: true

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- name: 📂 Checkout code
uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- run: cargo build
working-directory: prql-lib
- run: |
mv ../target/debug/libprql_lib.so ../prql-php/src/libprql_lib.so
ls -l ../target/debug/
uname -a
ls -lR ../prql-php/
working-directory: prql-lib
- name: 📦 Install dependencies using Composer
uses: php-actions/composer@v6
with:
args: --working-dir=prql-php
php_extensions: FFI
- name: 🧪 Run tests using PHPUnit
run: vendor/bin/phpunit tests
working-directory: prql-php
1 change: 1 addition & 0 deletions book/src/bindings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PRQL has bindings for many languages. These include:

- [Java](./java.md)
- [JavaScript](./javascript.md)
- [PHP](./php.md)
- [Python](./python.md)
- [R](./r.md)
- [Rust](./rust.md)
Expand Down
1 change: 1 addition & 0 deletions book/src/bindings/php.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{#include ../../../prql-php/README.md}}
1 change: 1 addition & 0 deletions prql-php/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor
25 changes: 25 additions & 0 deletions prql-php/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# prql-php

`prql-php` offers PHP bindings through FFI.

It provides the `Compiler` class which contains the `toJson` and `toSql`
max-sixty marked this conversation as resolved.
Show resolved Hide resolved
methods.

It's still at an early stage, and isn't published to Composer. Contributions are
welcome.

## Installation

The [PHP FFI extension](https://www.php.net/manual/en/book.ffi.php) needs to be
enabled. Set `ffi.enable` in your php.ini configuration file to `"true"`.

## Usage

```php
<?php

use Prql\Compiler\Compiler;

$prql = new Compiler();
$result = $prql->toSql("from employees");
```
37 changes: 37 additions & 0 deletions prql-php/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "prql/compiler",
"description": "PRQL compiler bindings.",
"keywords": [
"prql",
"sql"
],
"homepage": "https://prql-lang.org/",
"type": "library",
"license": "Apache-2.0",
"autoload": {
"psr-4": {
"Prql\\Compiler\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Prql\\Tests\\": "tests/"
}
},
"authors": [
{
"name": "Jonathan"
}
],
"support": {
"issues": "https://github.com/PRQL/prql/issues",
"source": "https://github.com/PRQL/prql",
"docs": "https://prql-lang.org/book/"
},
"require": {
"ext-ffi": "*"
},
"require-dev": {
"phpunit/phpunit": "^10"
}
}
Loading