From a0a7342b41daf32ddb78d3148a17e6938f855351 Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 21 Aug 2025 16:04:26 +1000 Subject: [PATCH 01/10] fix fpm setup on macos --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9bf41238..bcd481b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,9 +81,7 @@ jobs: - name: Setup php-fpm for Macos if: matrix.os == 'macos-14' run: | - brew install php@${{ matrix.php-version }} - echo "/opt/homebrew/opt/php@${{ matrix.php-version }}/bin" >> "$GITHUB_PATH" - echo "/opt/homebrew/opt/php@${{ matrix.php-version }}/sbin" >> "$GITHUB_PATH" + find /usr/local -name "php-fpm*" - name: PHP version run: | From ce06a8fada0346b85bf2e2c88de7b88d214ac6b9 Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 21 Aug 2025 16:19:50 +1000 Subject: [PATCH 02/10] more output --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcd481b6..bbc24bcc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,12 +81,15 @@ jobs: - name: Setup php-fpm for Macos if: matrix.os == 'macos-14' run: | - find /usr/local -name "php-fpm*" + find /opt/homebrew/Cellar -name "php-fpm*" - name: PHP version run: | + which php php --version + which php-fpm php-fpm --version + which php-config php-config || true [[ `php --version` == PHP\ ${{ matrix.php-version }}.* ]] || exit 1; From b57acb8cec6996fcd296e5ff6af966101311e872 Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 21 Aug 2025 16:22:57 +1000 Subject: [PATCH 03/10] remove php-fpm for macos --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbc24bcc..b1d8ceaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,16 +73,12 @@ jobs: - name: Setup php-fpm for Linux if: matrix.os == 'ubuntu-24.04' run: | + find /usr -name "php-fpm*" sudo apt-get update sudo apt-get install -y php${{ matrix.php-version }}-fpm sudo rm -f /usr/sbin/php-fpm sudo ln -s /usr/sbin/php-fpm${{ matrix.php-version }} /usr/sbin/php-fpm - - name: Setup php-fpm for Macos - if: matrix.os == 'macos-14' - run: | - find /opt/homebrew/Cellar -name "php-fpm*" - - name: PHP version run: | which php From 7191e3794fca77979207143b25fdeeda30d5f104 Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 21 Aug 2025 16:33:44 +1000 Subject: [PATCH 04/10] fix path --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1d8ceaf..4c5cf161 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,7 @@ jobs: - name: Setup php-fpm for Linux if: matrix.os == 'ubuntu-24.04' run: | - find /usr -name "php-fpm*" + find /usr/sbin -name "php-fpm*" sudo apt-get update sudo apt-get install -y php${{ matrix.php-version }}-fpm sudo rm -f /usr/sbin/php-fpm From 33728da1d037598042cf6320bb56c60f41526711 Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 21 Aug 2025 16:36:46 +1000 Subject: [PATCH 05/10] remove setup php-fpm setup-php action already installs php-fpm in the expected location --- .github/workflows/ci.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c5cf161..69792771 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,15 +70,6 @@ jobs: php-version: ${{ matrix.php-version }} tools: php-config - - name: Setup php-fpm for Linux - if: matrix.os == 'ubuntu-24.04' - run: | - find /usr/sbin -name "php-fpm*" - sudo apt-get update - sudo apt-get install -y php${{ matrix.php-version }}-fpm - sudo rm -f /usr/sbin/php-fpm - sudo ln -s /usr/sbin/php-fpm${{ matrix.php-version }} /usr/sbin/php-fpm - - name: PHP version run: | which php From 9d6da5b922188b5171cef14a886618f507a88f7f Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 21 Aug 2025 16:42:41 +1000 Subject: [PATCH 06/10] Revert "remove setup php-fpm" This reverts commit 33728da1d037598042cf6320bb56c60f41526711. --- .github/workflows/ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69792771..4c5cf161 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,15 @@ jobs: php-version: ${{ matrix.php-version }} tools: php-config + - name: Setup php-fpm for Linux + if: matrix.os == 'ubuntu-24.04' + run: | + find /usr/sbin -name "php-fpm*" + sudo apt-get update + sudo apt-get install -y php${{ matrix.php-version }}-fpm + sudo rm -f /usr/sbin/php-fpm + sudo ln -s /usr/sbin/php-fpm${{ matrix.php-version }} /usr/sbin/php-fpm + - name: PHP version run: | which php From 36b1874249237bd8b3791e5297720ad8a712f6ca Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 21 Aug 2025 16:43:17 +1000 Subject: [PATCH 07/10] remove debug output --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c5cf161..eb3a1eb6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,7 +73,6 @@ jobs: - name: Setup php-fpm for Linux if: matrix.os == 'ubuntu-24.04' run: | - find /usr/sbin -name "php-fpm*" sudo apt-get update sudo apt-get install -y php${{ matrix.php-version }}-fpm sudo rm -f /usr/sbin/php-fpm From 32c9fce89284715f1e8e2bd3abeec9b5038c404b Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 21 Aug 2025 21:10:14 +1000 Subject: [PATCH 08/10] use local web server instead of example.com --- examples/http-client/tests/integration.rs | 27 ++++++++++++++++++++++- examples/http-client/tests/php/router.php | 3 +++ examples/http-client/tests/php/test.php | 4 ++-- 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 examples/http-client/tests/php/router.php diff --git a/examples/http-client/tests/integration.rs b/examples/http-client/tests/integration.rs index c3831a61..e37d123f 100644 --- a/examples/http-client/tests/integration.rs +++ b/examples/http-client/tests/integration.rs @@ -32,5 +32,30 @@ pub static TESTS_PHP_DIR: LazyLock = LazyLock::new(|| { #[test] fn test_php() { + use std::process::Command; + use std::thread::sleep; + use std::time::Duration; + + let router = TESTS_PHP_DIR.join("router.php"); + let server = Command::new("php") + .arg("-S") + .arg("127.0.0.1:8000") + .arg("-t") + .arg(TESTS_PHP_DIR.to_str().unwrap()) + .arg(router.to_str().unwrap()) + .spawn() + .expect("Failed to start PHP built-in server"); + + struct ServerGuard(std::process::Child); + impl Drop for ServerGuard { + fn drop(&mut self) { + let _ = self.0.kill(); + } + } + let _guard = ServerGuard(server); + + // Give the server time to start + sleep(Duration::from_secs(1)); + test_php_script(&*DYLIB_PATH, TESTS_PHP_DIR.join("test.php")); -} +} \ No newline at end of file diff --git a/examples/http-client/tests/php/router.php b/examples/http-client/tests/php/router.php new file mode 100644 index 00000000..c0594981 --- /dev/null +++ b/examples/http-client/tests/php/router.php @@ -0,0 +1,3 @@ +cookie_store(true) ->build(); -$response = $client->get("https://example.com/")->send(); +$response = $client->get("http://localhost:8000/")->send(); var_dump([ "status" => $response->status(), "headers" => $response->headers(), @@ -35,4 +35,4 @@ $client->get("file:///")->send(); throw new AssertionError("no throw exception"); } catch (HttpClientException $e) { -} +} \ No newline at end of file From 5378d69906db7e91fdf54cdb27fab9ac041cc958 Mon Sep 17 00:00:00 2001 From: Brett McBride Date: Thu, 21 Aug 2025 21:11:48 +1000 Subject: [PATCH 09/10] add licence --- examples/http-client/tests/php/router.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/examples/http-client/tests/php/router.php b/examples/http-client/tests/php/router.php index c0594981..bd4c6b9e 100644 --- a/examples/http-client/tests/php/router.php +++ b/examples/http-client/tests/php/router.php @@ -1,3 +1,14 @@ Date: Thu, 21 Aug 2025 21:16:26 +1000 Subject: [PATCH 10/10] fmt --- examples/http-client/tests/integration.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/http-client/tests/integration.rs b/examples/http-client/tests/integration.rs index e37d123f..8331e5ab 100644 --- a/examples/http-client/tests/integration.rs +++ b/examples/http-client/tests/integration.rs @@ -32,9 +32,7 @@ pub static TESTS_PHP_DIR: LazyLock = LazyLock::new(|| { #[test] fn test_php() { - use std::process::Command; - use std::thread::sleep; - use std::time::Duration; + use std::{process::Command, thread::sleep, time::Duration}; let router = TESTS_PHP_DIR.join("router.php"); let server = Command::new("php") @@ -58,4 +56,4 @@ fn test_php() { sleep(Duration::from_secs(1)); test_php_script(&*DYLIB_PATH, TESTS_PHP_DIR.join("test.php")); -} \ No newline at end of file +}