Skip to content

Commit 35fd066

Browse files
committed
Update documents.
1 parent 5af4012 commit 35fd066

File tree

6 files changed

+11
-95
lines changed

6 files changed

+11
-95
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ A library that allows us to write PHP extensions using pure Rust and using safe
1414

1515
### Necessary
1616

17+
- **rust** 1.54 or later
1718
- **libclang** 9.0 or later
1819
- **php** 7.0 or later
1920

@@ -99,13 +100,16 @@ pub fn get_module() -> Module {
99100

100101
```bash
101102
# Optional, specify if php isn't installed globally.
102-
export PHP_CONFIG = <Your path of php-config>
103+
export PHP_CONFIG=<Your path of php-config>
103104

104105
# Build libmyapp.so.
105106
cargo build --release
106107

107-
# Install to php extension path, if you install php globally, you should use sudo.
108+
# Install to php extension path.
108109
cargo run --release -- install
110+
# Or if you install php globally, you should use sudo.
111+
# sudo ./target/release/myapp install
112+
109113
```
110114

111115
7. Edit your `php.ini`, add the below line.

examples/hello/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Hello world example.
66

77
```bash
88
# Optional, specify if php isn't installed globally.
9-
export PHP_CONFIG = <Your path of php-config>
9+
export PHP_CONFIG=<Your path of php-config>
1010
```
1111

1212
## Build

examples/http-client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Power by [reqwest::blocking](https://docs.rs/reqwest/0.11.4/reqwest/blocking/ind
88

99
```bash
1010
# Optional, specify if php isn't installed globally.
11-
export PHP_CONFIG = <Your path of php-config>
11+
export PHP_CONFIG=<Your path of php-config>
1212
```
1313

1414
## Build

examples/http-server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Power by [tokio](https://crates.io/crates/tokio) and [hyper](https://crates.io/c
88

99
```bash
1010
# Optional, specify if php isn't installed globally.
11-
export PHP_CONFIG = <Your path of php-config>
11+
export PHP_CONFIG=<Your path of php-config>
1212
```
1313

1414
## Build

examples/logging/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Log example.
66

77
```bash
88
# Optional, specify if php isn't installed globally.
9-
export PHP_CONFIG = <Your path of php-config>
9+
export PHP_CONFIG=<Your path of php-config>
1010
```
1111

1212
## Build

phper/src/lib.rs

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,5 @@
11
#![warn(rust_2018_idioms, clippy::dbg_macro, clippy::print_stdout)]
2-
3-
/*!
4-
## Rust ❤️ PHP
5-
6-
A library that allows us to write PHP extensions using pure Rust and using safe Rust whenever possible.
7-
8-
## Usage
9-
10-
1. Make sure `libclang` and `php` is installed.
11-
12-
```bash
13-
# If you are using debian like linux system:
14-
sudo apt install libclang-10-dev php-cli
15-
```
16-
17-
2. Create you cargo project, suppose your application is called myapp.
18-
19-
```bash
20-
cargo new myapp
21-
```
22-
23-
3. Add the dependencies and metadata to you Cargo project.
24-
25-
```toml
26-
[lib]
27-
crate-type = ["cdylib"]
28-
29-
[dependencies]
30-
phper = "0.3"
31-
```
32-
33-
4. Add these code to `main.rs`.
34-
35-
```no_run
36-
use phper::cmd::make;
37-
38-
fn main() {
39-
make();
40-
}
41-
```
42-
43-
5. Write you owned extension logic in `lib.rs`.
44-
45-
```no_run
46-
use phper::{php_get_module, modules::Module};
47-
48-
#[php_get_module]
49-
pub fn get_module() -> Module {
50-
let mut module = Module::new(
51-
env!("CARGO_PKG_NAME"),
52-
env!("CARGO_PKG_VERSION"),
53-
env!("CARGO_PKG_AUTHORS"),
54-
);
55-
56-
// ...
57-
58-
module
59-
}
60-
```
61-
62-
6. Build and install, if your php isn't installed globally, you should specify the path of `php-config`.
63-
64-
```bash
65-
# Specify if php isn't installed globally.
66-
export PHP_CONFIG = <Your path of php-config>
67-
68-
# Build libmyapp.so.
69-
cargo build --release
70-
71-
# Install to php extension path, if you install php globally, you should use sudo.
72-
cargo run --release -- install
73-
```
74-
75-
7. Edit your `php.ini`, add the below line.
76-
77-
```ini
78-
extension = myapp
79-
```
80-
81-
8. Enjoy.
82-
83-
## examples
84-
85-
See [examples](https://github.com/jmjoy/phper/tree/master/examples).
86-
87-
## License
88-
89-
[Unlicense](https://github.com/jmjoy/phper/blob/master/LICENSE).
90-
*/
2+
#![doc = include_str!("../README.md")]
913

924
#[macro_use]
935
mod macros;

0 commit comments

Comments
 (0)