Skip to content

Remove cmd mod and adjust phper-test. #74

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

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 2 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@ The framework that allows us to write PHP extensions using pure and safe Rust wh
phper = "<LATEST VERSION>"
```

1. Add these code to `main.rs`.

```rust,no_run
use phper::cmd::make;

fn main() {
make();
}
```

1. Create the `build.rs` ( Adapting MacOS ).

```rust,no_run
Expand All @@ -98,7 +88,7 @@ The framework that allows us to write PHP extensions using pure and safe Rust wh
#[php_get_module]
pub fn get_module() -> Module {
let mut module = Module::new(
env!("CARGO_PKG_NAME"),
env!("CARGO_CRATE_NAME"),
env!("CARGO_PKG_VERSION"),
env!("CARGO_PKG_AUTHORS"),
);
Expand All @@ -119,10 +109,7 @@ The framework that allows us to write PHP extensions using pure and safe Rust wh
cargo build --release

# Install to php extension path.
cargo run --release -- install
# Or if you install php globally, you should use sudo.
# sudo ./target/release/myapp install

cp target/release/libmyapp.so `${PHP_CONFIG:=php-config} --extension-dir`
```

1. Edit your `php.ini`, add the below line.
Expand Down
2 changes: 1 addition & 1 deletion examples/hello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cargo test --release
## Install

```bash
cargo run --release -- install
cp target/release/libhello.so `${PHP_CONFIG:=php-config} --extension-dir`
```

## License
Expand Down
2 changes: 1 addition & 1 deletion examples/hello/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn throw_exception(_: &mut [ZVal]) -> phper::Result<()> {
#[php_get_module]
pub fn get_module() -> Module {
let mut module = Module::new(
env!("CARGO_PKG_NAME"),
env!("CARGO_CRATE_NAME"),
env!("CARGO_PKG_VERSION"),
env!("CARGO_PKG_AUTHORS"),
);
Expand Down
15 changes: 0 additions & 15 deletions examples/hello/src/main.rs

This file was deleted.

17 changes: 13 additions & 4 deletions examples/hello/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path};
use std::{env, path::Path};
use phper_test::{cli::test_php_scripts, utils::get_lib_path};
use std::{
env,
path::{Path, PathBuf},
};

#[test]
fn test_php() {
test_php_scripts_with_lib(
get_lib_path(env!("CARGO_BIN_EXE_hello")),
test_php_scripts(
get_lib_path(
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("..")
.join("..")
.join("target"),
"hello",
),
&[&Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("php")
Expand Down
2 changes: 1 addition & 1 deletion examples/http-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cargo test --release
## Install

```bash
cargo run --release -- install
cp target/release/libhttp_client.so `${PHP_CONFIG:=php-config} --extension-dir`
```

## License
Expand Down
2 changes: 1 addition & 1 deletion examples/http-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub mod utils;
#[php_get_module]
pub fn get_module() -> Module {
let mut module = Module::new(
env!("CARGO_PKG_NAME"),
env!("CARGO_CRATE_NAME"),
env!("CARGO_PKG_VERSION"),
env!("CARGO_PKG_AUTHORS"),
);
Expand Down
15 changes: 0 additions & 15 deletions examples/http-client/src/main.rs

This file was deleted.

17 changes: 13 additions & 4 deletions examples/http-client/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

use phper_test::{cli::test_php_scripts_with_lib, utils::get_lib_path};
use std::{env, path::Path};
use phper_test::{cli::test_php_scripts, utils::get_lib_path};
use std::{
env,
path::{Path, PathBuf},
};

#[test]
fn test_php() {
test_php_scripts_with_lib(
get_lib_path(env!("CARGO_BIN_EXE_http-client")),
test_php_scripts(
get_lib_path(
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("..")
.join("..")
.join("target"),
"http_client",
),
&[&Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("php")
Expand Down
2 changes: 1 addition & 1 deletion examples/http-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cargo test --release
## Install

```bash
cargo run --release -- install
cp target/release/libhttp_server.so `${PHP_CONFIG:=php-config} --extension-dir`
```

## License
Expand Down
2 changes: 1 addition & 1 deletion examples/http-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub mod utils;
#[php_get_module]
pub fn get_module() -> Module {
let mut module = Module::new(
env!("CARGO_PKG_NAME"),
env!("CARGO_CRATE_NAME"),
env!("CARGO_PKG_VERSION"),
env!("CARGO_PKG_AUTHORS"),
);
Expand Down
15 changes: 0 additions & 15 deletions examples/http-server/src/main.rs

This file was deleted.

19 changes: 15 additions & 4 deletions examples/http-server/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,26 @@
// See the Mulan PSL v2 for more details.

use hyper::header::CONTENT_TYPE;
use phper_test::{cli::test_long_term_php_script_with_condition_and_lib, utils::get_lib_path};
use phper_test::{cli::test_long_term_php_script_with_condition, utils::get_lib_path};
use reqwest::Client;
use std::{env, path::Path, thread::sleep, time::Duration};
use std::{
env,
path::{Path, PathBuf},
thread::sleep,
time::Duration,
};
use tokio::runtime;

#[test]
fn test_php() {
test_long_term_php_script_with_condition_and_lib(
get_lib_path(env!("CARGO_BIN_EXE_http-server")),
test_long_term_php_script_with_condition(
get_lib_path(
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("..")
.join("..")
.join("target"),
"http_server",
),
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("php")
Expand Down
2 changes: 1 addition & 1 deletion examples/logging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cargo test --release
## Install

```bash
cargo run --release -- install
cp target/release/liblogging.so `${PHP_CONFIG:=php-config} --extension-dir`
```

## License
Expand Down
2 changes: 1 addition & 1 deletion examples/logging/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use phper::{
#[php_get_module]
pub fn get_module() -> Module {
let mut module = Module::new(
env!("CARGO_PKG_NAME"),
env!("CARGO_CRATE_NAME"),
env!("CARGO_PKG_VERSION"),
env!("CARGO_PKG_AUTHORS"),
);
Expand Down
15 changes: 0 additions & 15 deletions examples/logging/src/main.rs

This file was deleted.

18 changes: 14 additions & 4 deletions examples/logging/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,27 @@
// NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

use phper_test::{cli::test_php_scripts_with_condition_and_lib, utils::get_lib_path};
use std::{env, path::Path, str};
use phper_test::{cli::test_php_scripts_with_condition, utils::get_lib_path};
use std::{
env,
path::{Path, PathBuf},
str,
};

#[test]
fn test_php() {
let base_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("php");

test_php_scripts_with_condition_and_lib(
get_lib_path(env!("CARGO_BIN_EXE_logging")),
test_php_scripts_with_condition(
get_lib_path(
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("..")
.join("..")
.join("target"),
"logging",
),
&[
(&base_dir.join("test_php_say.php"), &|output| {
let stdout = str::from_utf8(&output.stdout).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion phper-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn c_str_ptr(input: TokenStream) -> TokenStream {
/// #[php_get_module]
/// pub fn get_module() -> Module {
/// let mut module = Module::new(
/// env!("CARGO_PKG_NAME"),
/// env!("CARGO_CRATE_NAME"),
/// env!("CARGO_PKG_VERSION"),
/// env!("CARGO_PKG_AUTHORS"),
/// );
Expand Down
Loading