Skip to content

Commit 7902372

Browse files
authored
fix fpm setup on macos (#218)
1 parent d747288 commit 7902372

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,13 @@ jobs:
7878
sudo rm -f /usr/sbin/php-fpm
7979
sudo ln -s /usr/sbin/php-fpm${{ matrix.php-version }} /usr/sbin/php-fpm
8080
81-
- name: Setup php-fpm for Macos
82-
if: matrix.os == 'macos-14'
83-
run: |
84-
brew install php@${{ matrix.php-version }}
85-
echo "/opt/homebrew/opt/php@${{ matrix.php-version }}/bin" >> "$GITHUB_PATH"
86-
echo "/opt/homebrew/opt/php@${{ matrix.php-version }}/sbin" >> "$GITHUB_PATH"
87-
8881
- name: PHP version
8982
run: |
83+
which php
9084
php --version
85+
which php-fpm
9186
php-fpm --version
87+
which php-config
9288
php-config || true
9389
9490
[[ `php --version` == PHP\ ${{ matrix.php-version }}.* ]] || exit 1;

examples/http-client/tests/integration.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,28 @@ pub static TESTS_PHP_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
3232

3333
#[test]
3434
fn test_php() {
35+
use std::{process::Command, thread::sleep, time::Duration};
36+
37+
let router = TESTS_PHP_DIR.join("router.php");
38+
let server = Command::new("php")
39+
.arg("-S")
40+
.arg("127.0.0.1:8000")
41+
.arg("-t")
42+
.arg(TESTS_PHP_DIR.to_str().unwrap())
43+
.arg(router.to_str().unwrap())
44+
.spawn()
45+
.expect("Failed to start PHP built-in server");
46+
47+
struct ServerGuard(std::process::Child);
48+
impl Drop for ServerGuard {
49+
fn drop(&mut self) {
50+
let _ = self.0.kill();
51+
}
52+
}
53+
let _guard = ServerGuard(server);
54+
55+
// Give the server time to start
56+
sleep(Duration::from_secs(1));
57+
3558
test_php_script(&*DYLIB_PATH, TESTS_PHP_DIR.join("test.php"));
3659
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
// Copyright (c) 2022 PHPER Framework Team
4+
// PHPER is licensed under Mulan PSL v2.
5+
// You can use this software according to the terms and conditions of the Mulan
6+
// PSL v2. You may obtain a copy of Mulan PSL v2 at:
7+
// http://license.coscl.org.cn/MulanPSL2
8+
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
9+
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
10+
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11+
// See the Mulan PSL v2 for more details.
12+
13+
header('Content-Type: text/plain');
14+
echo "Hello phper!";

examples/http-client/tests/php/test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
->cookie_store(true)
2525
->build();
2626

27-
$response = $client->get("https://example.com/")->send();
27+
$response = $client->get("http://localhost:8000/")->send();
2828
var_dump([
2929
"status" => $response->status(),
3030
"headers" => $response->headers(),
@@ -35,4 +35,4 @@
3535
$client->get("file:///")->send();
3636
throw new AssertionError("no throw exception");
3737
} catch (HttpClientException $e) {
38-
}
38+
}

0 commit comments

Comments
 (0)