diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e17eae83..db7f30f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,6 +88,23 @@ jobs: override: true components: clippy + - name: Cargo generate lockfile + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: generate-lockfile + + - name: Setup cargo cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.os }}-ci-${{ matrix.php-version }}-${{ hashFiles('**/Cargo.lock') }} + - name: Cargo fmt uses: actions-rs/cargo@v1 with: @@ -159,6 +176,23 @@ jobs: toolchain: stable override: true + - name: Cargo generate lockfile + uses: actions-rs/cargo@v1 + with: + toolchain: stable + command: generate-lockfile + + - name: Setup cargo cache + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.os }}-check-${{ matrix.php-version }}-${{ matrix.features }}-${{ hashFiles('**/Cargo.lock') }} + - name: Cargo check phper-sys uses: actions-rs/cargo@v1 with: diff --git a/README.md b/README.md index 5c8c866b..41325f05 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,18 @@ The framework that allows us to write PHP extensions using pure and safe Rust wh } ``` +1. Create the `build.rs` ( Adapting MacOS ). + + ```rust,no_run + fn main() { + #[cfg(target_os = "macos")] + { + println!("cargo:rustc-link-arg=-undefined"); + println!("cargo:rustc-link-arg=dynamic_lookup"); + } + } + ``` + 1. Write you owned extension logic in `lib.rs`. ```rust @@ -125,6 +137,10 @@ The framework that allows us to write PHP extensions using pure and safe Rust wh See [examples](https://github.com/phper-framework/phper/tree/master/examples). +## The projects using PHPER + +- [apache/skywalking-php](https://github.com/apache/skywalking-php) - The PHP Agent for Apache SkyWalking, which provides the native tracing abilities for PHP project. + ## License [MulanPSL-2.0](https://github.com/phper-framework/phper/blob/master/LICENSE). diff --git a/examples/hello/Cargo.toml b/examples/hello/Cargo.toml index c7e1c4ec..4a3e35d2 100644 --- a/examples/hello/Cargo.toml +++ b/examples/hello/Cargo.toml @@ -29,10 +29,10 @@ path = "src/_reexport.rs" crate-type = ["cdylib"] [dependencies] -phper = { version = "0.5.0", path = "../../phper" } +phper = { version = "0.5.1", path = "../../phper" } [dev-dependencies] -phper-test = { version = "0.5.0", path = "../../phper-test" } +phper-test = { version = "0.5.1", path = "../../phper-test" } [build-dependencies] -phper-build = { version = "0.5.0", path = "../../phper-build" } +phper-build = { version = "0.5.1", path = "../../phper-build" } diff --git a/examples/http-client/Cargo.toml b/examples/http-client/Cargo.toml index e849983c..eb87f3c1 100644 --- a/examples/http-client/Cargo.toml +++ b/examples/http-client/Cargo.toml @@ -32,9 +32,9 @@ crate-type = ["cdylib"] anyhow = "1.0.58" bytes = "1.1.0" indexmap = "1.9.1" -phper = { version = "0.5.0", path = "../../phper" } +phper = { version = "0.5.1", path = "../../phper" } reqwest = { version = "0.11.11", features = ["blocking", "cookies"] } thiserror = "1.0.31" [dev-dependencies] -phper-test = { version = "0.5.0", path = "../../phper-test" } +phper-test = { version = "0.5.1", path = "../../phper-test" } diff --git a/examples/http-server/Cargo.toml b/examples/http-server/Cargo.toml index 27d2da51..fffc54c9 100644 --- a/examples/http-server/Cargo.toml +++ b/examples/http-server/Cargo.toml @@ -30,10 +30,10 @@ crate-type = ["cdylib"] [dependencies] hyper = { version = "0.14.20", features = ["http1", "runtime", "server"] } -phper = { version = "0.5.0", path = "../../phper" } +phper = { version = "0.5.1", path = "../../phper" } thiserror = "1.0.31" tokio = { version = "1.19.2", features = ["full"] } [dev-dependencies] -phper-test = { version = "0.5.0", path = "../../phper-test" } +phper-test = { version = "0.5.1", path = "../../phper-test" } reqwest = "0.11.11" diff --git a/examples/logging/Cargo.toml b/examples/logging/Cargo.toml index 92c95e6d..44bc37a3 100644 --- a/examples/logging/Cargo.toml +++ b/examples/logging/Cargo.toml @@ -30,10 +30,10 @@ crate-type = ["cdylib"] [dependencies] anyhow = "1.0.58" -phper = { version = "0.5.0", path = "../../phper" } +phper = { version = "0.5.1", path = "../../phper" } [dev-dependencies] -phper-test = { version = "0.5.0", path = "../../phper-test" } +phper-test = { version = "0.5.1", path = "../../phper-test" } [build-dependencies] -phper-build = { version = "0.5.0", path = "../../phper-build" } +phper-build = { version = "0.5.1", path = "../../phper-build" } diff --git a/phper-alloc/Cargo.toml b/phper-alloc/Cargo.toml index 4e394d18..bb673284 100644 --- a/phper-alloc/Cargo.toml +++ b/phper-alloc/Cargo.toml @@ -10,7 +10,7 @@ [package] name = "phper-alloc" -version = "0.5.0" +version = "0.5.1" authors = ["PHPER Framework Team", "jmjoy "] edition = "2021" rust-version = "1.56" @@ -22,7 +22,7 @@ keywords = ["php", "alloc"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -phper-sys = { version = "0.5.0", path = "../phper-sys" } +phper-sys = { version = "0.5.1", path = "../phper-sys" } [build-dependencies] -phper-build = { version = "0.5.0", path = "../phper-build" } +phper-build = { version = "0.5.1", path = "../phper-build" } diff --git a/phper-build/Cargo.toml b/phper-build/Cargo.toml index 0de4bb46..a0d70473 100644 --- a/phper-build/Cargo.toml +++ b/phper-build/Cargo.toml @@ -10,7 +10,7 @@ [package] name = "phper-build" -version = "0.5.0" +version = "0.5.1" authors = ["PHPER Framework Team", "jmjoy "] edition = "2021" rust-version = "1.56" @@ -22,4 +22,4 @@ keywords = ["php", "binding"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -phper-sys = { version = "0.5.0", path = "../phper-sys" } +phper-sys = { version = "0.5.1", path = "../phper-sys" } diff --git a/phper-macros/Cargo.toml b/phper-macros/Cargo.toml index dc5a174f..374f88d6 100644 --- a/phper-macros/Cargo.toml +++ b/phper-macros/Cargo.toml @@ -10,7 +10,7 @@ [package] name = "phper-macros" -version = "0.5.0" +version = "0.5.1" authors = ["PHPER Framework Team", "jmjoy "] edition = "2021" rust-version = "1.56" diff --git a/phper-sys/Cargo.toml b/phper-sys/Cargo.toml index 64ca5648..204565fb 100644 --- a/phper-sys/Cargo.toml +++ b/phper-sys/Cargo.toml @@ -10,7 +10,7 @@ [package] name = "phper-sys" -version = "0.5.0" +version = "0.5.1" authors = ["PHPER Framework Team", "jmjoy "] edition = "2021" rust-version = "1.56" diff --git a/phper-test/Cargo.toml b/phper-test/Cargo.toml index 710e37d1..1162c87c 100644 --- a/phper-test/Cargo.toml +++ b/phper-test/Cargo.toml @@ -10,7 +10,7 @@ [package] name = "phper-test" -version = "0.5.0" +version = "0.5.1" authors = ["PHPER Framework Team", "jmjoy "] edition = "2021" rust-version = "1.56" @@ -25,10 +25,10 @@ keywords = ["php", "binding"] fpm = ["fastcgi-client", "tokio/full"] [dependencies] -fastcgi-client = { version = "0.7.0", optional = true } +fastcgi-client = { version = "0.8.0", optional = true } libc = "0.2.126" once_cell = "1.13.0" -phper-macros = { version = "0.5.0", path = "../phper-macros" } +phper-macros = { version = "0.5.1", path = "../phper-macros" } tempfile = "3.3.0" tokio = { version = "1.19.2", optional = true } diff --git a/phper-test/src/fpm.rs b/phper-test/src/fpm.rs index ef03bc8e..14af975d 100644 --- a/phper-test/src/fpm.rs +++ b/phper-test/src/fpm.rs @@ -125,40 +125,42 @@ pub fn test_fpm_request( let local_addr = stream.local_addr().unwrap(); let peer_addr = stream.peer_addr().unwrap(); let local_ip = local_addr.ip().to_string(); - let local_addr = local_addr.port().to_string(); + let local_port = local_addr.port(); let peer_ip = peer_addr.ip().to_string(); - let peer_port = peer_addr.port().to_string(); + let peer_port = peer_addr.port(); - let mut client = Client::new(stream, false); + let client = Client::new(stream); let mut params = Params::default() - .set_request_method(method) - .set_script_name(request_uri) - .set_script_filename(script_filename) - .set_request_uri(request_uri) - .set_document_uri(script_name) - .set_remote_addr(&local_ip) - .set_remote_port(&local_addr) - .set_server_addr(&peer_ip) - .set_server_port(&peer_port) - .set_server_name("phper-test"); + .request_method(method) + .script_name(request_uri) + .script_filename(script_filename) + .request_uri(request_uri) + .document_uri(script_name) + .remote_addr(&local_ip) + .remote_port(local_port) + .server_addr(&peer_ip) + .server_port(peer_port) + .server_name("phper-test"); if let Some(content_type) = &content_type { - params = params.set_content_type(content_type); + params = params.content_type(content_type); } - let mut len = String::new(); if let Some(body) = &body { - len += &body.len().to_string(); - params = params.set_content_length(&len); + params = params.content_length(body.len()); } let response = if let Some(body) = body { - client.execute(Request::new(params, body.as_ref())).await + client + .execute_once(Request::new(params, body.as_ref())) + .await } else { - client.execute(Request::new(params, &mut io::empty())).await + client + .execute_once(Request::new(params, &mut io::empty())) + .await }; let output = response.unwrap(); - let stdout = output.get_stdout().unwrap_or_default(); - let stderr = output.get_stderr().unwrap_or_default(); + let stdout = output.stdout.unwrap_or_default(); + let stderr = output.stderr.unwrap_or_default(); let no_error = stderr.is_empty(); diff --git a/phper/Cargo.toml b/phper/Cargo.toml index eb8ede25..80d34f62 100644 --- a/phper/Cargo.toml +++ b/phper/Cargo.toml @@ -10,7 +10,7 @@ [package] name = "phper" -version = "0.5.0" +version = "0.5.1" authors = ["PHPER Framework Team", "jmjoy "] edition = "2021" rust-version = "1.56" @@ -18,7 +18,7 @@ description = "The framework that allows us to write PHP extensions using pure a repository = "https://github.com/jmjoy/phper.git" documentation = "https://docs.rs/phper" license = "MulanPSL-2.0" -readme = "../README.md" +readme = "README.md" keywords = ["php", "binding", "extension", "module"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -30,11 +30,11 @@ dashmap = "5.3.4" derive_more = "0.99.17" indexmap = "1.9.1" once_cell = "1.13.0" -phper-alloc = { version = "0.5.0", path = "../phper-alloc" } -phper-macros = { version = "0.5.0", path = "../phper-macros" } -phper-sys = { version = "0.5.0", path = "../phper-sys" } +phper-alloc = { version = "0.5.1", path = "../phper-alloc" } +phper-macros = { version = "0.5.1", path = "../phper-macros" } +phper-sys = { version = "0.5.1", path = "../phper-sys" } thiserror = "1.0.31" [build-dependencies] -phper-build = { version = "0.5.0", path = "../phper-build" } -phper-sys = { version = "0.5.0", path = "../phper-sys" } +phper-build = { version = "0.5.1", path = "../phper-build" } +phper-sys = { version = "0.5.1", path = "../phper-sys" } diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index 41007189..eb2eb809 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -28,7 +28,7 @@ crate-type = ["cdylib"] [dependencies] indexmap = "1.9.1" -phper = { version = "0.5.0", path = "../../phper" } +phper = { version = "0.5.1", path = "../../phper" } [dev-dependencies] -phper-test = { version = "0.5.0", path = "../../phper-test", features = ["fpm"] } +phper-test = { version = "0.5.1", path = "../../phper-test", features = ["fpm"] }