Skip to content

Commit 5e3347f

Browse files
authored
Merge pull request #3 from jmjoy/dynamic-develop
2 parents cbfa3af + fc5c3df commit 5e3347f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1885
-2224
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ on:
77
branches: [ "**" ]
88

99
env:
10-
CARGO_TERM_COLOR: always
11-
# RUST_BACKTRACE: 1
1210
# RUST_LOG: debug
11+
CARGO_TERM_COLOR: always
12+
RUST_BACKTRACE: 1
1313
RUSTFLAGS: "-D warnings"
1414

1515
jobs:
@@ -26,6 +26,7 @@ jobs:
2626
- "7.2"
2727
- "7.3"
2828
- "7.4"
29+
- "8.0"
2930

3031
runs-on: ${{ matrix.os }}
3132
steps:
@@ -41,38 +42,43 @@ jobs:
4142
- name: Checkout
4243
uses: actions/checkout@v2
4344

44-
- name: Install Rust
45+
- name: Install Rust Nightly
4546
uses: actions-rs/toolchain@v1
4647
with:
4748
toolchain: nightly
4849
override: true
49-
components: rustfmt, clippy
50+
components: rustfmt
5051

51-
# - name: Install Cargo make
52-
# uses: actions-rs/cargo@v1
53-
# with:
54-
# command: install
55-
# args: cargo-make
52+
- name: Install Rust Stable
53+
uses: actions-rs/toolchain@v1
54+
with:
55+
toolchain: stable
56+
override: true
57+
components: rustfmt
5658

5759
- name: Cargo fmt
5860
uses: actions-rs/cargo@v1
5961
with:
62+
toolchain: nightly
6063
command: fmt
6164
args: --all -- --check
6265

6366
- name: Cargo build
6467
uses: actions-rs/cargo@v1
6568
with:
69+
toolchain: stable
6670
command: build
6771
args: --release
6872

6973
- name: Cargo test
7074
uses: actions-rs/cargo@v1
7175
with:
76+
toolchain: stable
7277
command: test
7378
args: --release -- --nocapture
7479

7580
- name: Cargo doc
7681
uses: actions-rs/cargo@v1
7782
with:
83+
toolchain: stable
7884
command: doc

.rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
imports_granularity = "Crate"

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ members = [
99

1010
# internal
1111
"examples/hello",
12-
"examples/hello-class",
13-
"examples/mini-curl",
12+
# "examples/mini-curl",
1413
]

README.md

Lines changed: 100 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,119 @@
11
# PHPer
22

3-
A library that allows us to write PHP extensions using pure Rust and using safe Rust whenever possible.
3+
[![crates](https://img.shields.io/crates/v/phper?style=flat-square)](https://crates.io/crates/phper)
4+
[![](https://img.shields.io/docsrs/phper?style=flat-square)](https://docs.rs/phper)
45

5-
***Now the project is still under development.***
6+
A library that allows us to write PHP extensions using pure Rust and using safe Rust whenever possible.
67

78
## Requirement
89

9-
- rust nightly channel (now)
10-
- libclang >= 9
10+
### Necessary
11+
12+
**libclang** version >= 9
13+
14+
**php** version >= 7
15+
16+
### Tested Support
17+
18+
**os**
19+
20+
- linux
21+
22+
**php**
23+
24+
*version*
25+
26+
- 7.0
27+
- 7.1
28+
- 7.2
29+
- 7.3
30+
- 7.4
31+
- 8.0
32+
33+
*mode*
34+
35+
- nts
36+
37+
*sapi*
38+
39+
- cli
1140

1241
## Usage
1342

14-
Now see [examples](examples).
43+
1. Make sure `libclang` and `php` is installed.
44+
45+
```bash
46+
# If you are using debian like linux system:
47+
sudo apt install libclang-10-dev php-cli
48+
```
1549

16-
<!--
17-
First you have to install `cargo-generate`:
50+
2. Create you cargo project, suppose your application is called myapp.
1851

19-
# ```bash
20-
cargo install cargo-generate
52+
```bash
53+
cargo new myapp
2154
```
2255

23-
Then create a PHP extension project from the [template](https://github.com/jmjoy/phper-ext-skel.git):
56+
3. Add the dependencies and metadata to you Cargo project.
57+
58+
```toml
59+
[lib]
60+
crate-type = ["cdylib"]
61+
62+
[dependencies]
63+
phper = "0.2"
64+
```
65+
66+
4. Add these code to `main.rs`.
67+
68+
```rust
69+
use phper::cmd::make;
70+
71+
fn main() {
72+
make();
73+
}
74+
```
75+
76+
5. Write you owned extension logic in `lib.rs`.
77+
78+
```rust
79+
use phper::{php_get_module, modules::Module};
80+
81+
#[php_get_module]
82+
pub fn get_module(module: &mut Module) {
83+
// set module metadata
84+
module.set_name(env!("CARGO_PKG_NAME"));
85+
module.set_version(env!("CARGO_PKG_VERSION"));
86+
module.set_author(env!("CARGO_PKG_AUTHORS"));
87+
88+
// ...
89+
}
90+
```
91+
92+
6. Build and install, if your php isn't installed globally, you should specify the path of `php-config`.
2493

2594
```bash
26-
cargo generate --git https://github.com/jmjoy/phper-ext-skel.git
95+
# Specify if php isn't installed globally.
96+
export PHP_CONFIG = <Your path of php-config>
97+
98+
# Build libmyapp.so.
99+
cargo build --release
100+
101+
# Install to php extension path, if you install php globally, you should use sudo.
102+
cargo run --release -- install
27103
```
28-
-->
104+
105+
7. Edit your `php.ini`, add the below line.
106+
107+
```ini
108+
extension = myapp
109+
```
110+
111+
8. Enjoy.
112+
113+
## examples
114+
115+
See [examples](https://github.com/jmjoy/phper/tree/master/examples).
29116

30117
## License
31118

32-
[Unlicense](LICENSE).
119+
[Unlicense](https://github.com/jmjoy/phper/blob/master/LICENSE).

examples/hello-class/Cargo.toml

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/hello-class/Makefile.toml

Lines changed: 0 additions & 30 deletions
This file was deleted.

examples/hello-class/build.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)