@@ -21,9 +21,9 @@ A library that allows us to write PHP extensions using pure Rust and using safe
21
21
### Tested Support
22
22
23
23
- ** OS**
24
- - [x] linux
25
- - [ ] macos
26
- - [ ] windows
24
+ - [x] linux
25
+ - [ ] macos
26
+ - [ ] windows
27
27
- ** PHP**
28
28
- ** version**
29
29
- [x] 7.0
@@ -47,79 +47,79 @@ A library that allows us to write PHP extensions using pure Rust and using safe
47
47
48
48
1 . Make sure ` libclang ` and ` php ` is installed.
49
49
50
- ``` bash
51
- # If you are using debian like linux system:
52
- sudo apt install llvm-10-dev libclang-10-dev php-cli
53
- ```
54
-
55
- 2 . Create you cargo project, suppose your application is called myapp.
56
-
57
- ``` bash
58
- cargo new myapp
59
- ```
60
-
61
- 3 . Add the dependencies and metadata to you Cargo project.
62
-
63
- ``` toml
64
- [lib ]
65
- crate-type = [" cdylib" ]
66
-
67
- [dependencies ]
68
- phper = " 0.3 "
69
- ```
70
-
71
- 4 . Add these code to ` main.rs ` .
72
-
73
- ``` rust,no_run
74
- use phper::cmd::make;
75
-
76
- fn main() {
77
- make();
78
- }
79
- ```
80
-
81
- 5 . Write you owned extension logic in ` lib.rs ` .
82
-
83
- ``` rust
84
- use phper :: {php_get_module, modules :: Module };
85
-
86
- #[php_get_module]
87
- pub fn get_module () -> Module {
88
- let mut module = Module :: new (
89
- env! (" CARGO_PKG_NAME" ),
90
- env! (" CARGO_PKG_VERSION" ),
91
- env! (" CARGO_PKG_AUTHORS" ),
92
- );
93
-
94
- // ...
95
-
96
- module
97
- }
98
- ```
99
-
100
- 6 . Build and install, if your php isn't installed globally, you should specify the path of ` php-config ` .
101
-
102
- ``` bash
103
- # Optional, specify if php isn't installed globally.
104
- export PHP_CONFIG=< Your path of php-config>
105
-
106
- # Build libmyapp.so.
107
- cargo build --release
108
-
109
- # Install to php extension path.
110
- cargo run --release -- install
111
- # Or if you install php globally, you should use sudo.
112
- # sudo ./target/release/myapp install
113
-
114
- ```
115
-
116
- 7 . Edit your ` php.ini ` , add the below line.
117
-
118
- ``` ini
119
- extension = myapp
120
- ```
121
-
122
- 8 . Enjoy.
50
+ ``` bash
51
+ # If you are using debian like linux system:
52
+ sudo apt install llvm-10-dev libclang-10-dev php-cli
53
+ ```
54
+
55
+ 1 . Create you cargo project, suppose your application is called myapp.
56
+
57
+ ``` bash
58
+ cargo new myapp
59
+ ```
60
+
61
+ 1 . Add the dependencies and metadata to you Cargo project.
62
+
63
+ ``` toml
64
+ [lib ]
65
+ crate-type = [" cdylib" ]
66
+
67
+ [dependencies ]
68
+ phper = " <LATEST VERSION> "
69
+ ```
70
+
71
+ 1 . Add these code to ` main.rs ` .
72
+
73
+ ``` rust,no_run
74
+ use phper::cmd::make;
75
+
76
+ fn main() {
77
+ make();
78
+ }
79
+ ```
80
+
81
+ 1 . Write you owned extension logic in ` lib.rs ` .
82
+
83
+ ``` rust
84
+ use phper :: {php_get_module, modules :: Module };
85
+
86
+ #[php_get_module]
87
+ pub fn get_module () -> Module {
88
+ let mut module = Module :: new (
89
+ env! (" CARGO_PKG_NAME" ),
90
+ env! (" CARGO_PKG_VERSION" ),
91
+ env! (" CARGO_PKG_AUTHORS" ),
92
+ );
93
+
94
+ // ...
95
+
96
+ module
97
+ }
98
+ ```
99
+
100
+ 1 . Build and install, if your php isn't installed globally, you should specify the path of ` php-config ` .
101
+
102
+ ``` bash
103
+ # Optional, specify if php isn't installed globally.
104
+ # export PHP_CONFIG=<Your path of php-config>
105
+
106
+ # Build libmyapp.so.
107
+ cargo build --release
108
+
109
+ # Install to php extension path.
110
+ cargo run --release -- install
111
+ # Or if you install php globally, you should use sudo.
112
+ # sudo ./target/release/myapp install
113
+
114
+ ```
115
+
116
+ 1 . Edit your ` php.ini ` , add the below line.
117
+
118
+ ``` ini
119
+ extension = myapp
120
+ ```
121
+
122
+ 1 . Enjoy.
123
123
124
124
## Examples
125
125
0 commit comments