Skip to content

Dynamic develop #3

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 20 commits into from
Apr 18, 2021
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
24 changes: 15 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ on:
branches: [ "**" ]

env:
CARGO_TERM_COLOR: always
# RUST_BACKTRACE: 1
# RUST_LOG: debug
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"

jobs:
Expand All @@ -26,6 +26,7 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
- "8.0"

runs-on: ${{ matrix.os }}
steps:
Expand All @@ -41,38 +42,43 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Install Rust
- name: Install Rust Nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
components: rustfmt

# - name: Install Cargo make
# uses: actions-rs/cargo@v1
# with:
# command: install
# args: cargo-make
- name: Install Rust Stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt

- name: Cargo fmt
uses: actions-rs/cargo@v1
with:
toolchain: nightly
command: fmt
args: --all -- --check

- name: Cargo build
uses: actions-rs/cargo@v1
with:
toolchain: stable
command: build
args: --release

- name: Cargo test
uses: actions-rs/cargo@v1
with:
toolchain: stable
command: test
args: --release -- --nocapture

- name: Cargo doc
uses: actions-rs/cargo@v1
with:
toolchain: stable
command: doc
1 change: 1 addition & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
imports_granularity = "Crate"
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ members = [

# internal
"examples/hello",
"examples/hello-class",
"examples/mini-curl",
# "examples/mini-curl",
]
113 changes: 100 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,119 @@
# PHPer

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

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

## Requirement

- rust nightly channel (now)
- libclang >= 9
### Necessary

**libclang** version >= 9

**php** version >= 7

### Tested Support

**os**

- linux

**php**

*version*

- 7.0
- 7.1
- 7.2
- 7.3
- 7.4
- 8.0

*mode*

- nts

*sapi*

- cli

## Usage

Now see [examples](examples).
1. Make sure `libclang` and `php` is installed.

```bash
# If you are using debian like linux system:
sudo apt install libclang-10-dev php-cli
```

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

# ```bash
cargo install cargo-generate
```bash
cargo new myapp
```

Then create a PHP extension project from the [template](https://github.com/jmjoy/phper-ext-skel.git):
3. Add the dependencies and metadata to you Cargo project.

```toml
[lib]
crate-type = ["cdylib"]

[dependencies]
phper = "0.2"
```

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

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

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

5. Write you owned extension logic in `lib.rs`.

```rust
use phper::{php_get_module, modules::Module};

#[php_get_module]
pub fn get_module(module: &mut Module) {
// set module metadata
module.set_name(env!("CARGO_PKG_NAME"));
module.set_version(env!("CARGO_PKG_VERSION"));
module.set_author(env!("CARGO_PKG_AUTHORS"));

// ...
}
```

6. Build and install, if your php isn't installed globally, you should specify the path of `php-config`.

```bash
cargo generate --git https://github.com/jmjoy/phper-ext-skel.git
# Specify if php isn't installed globally.
export PHP_CONFIG = <Your path of php-config>

# Build libmyapp.so.
cargo build --release

# Install to php extension path, if you install php globally, you should use sudo.
cargo run --release -- install
```
-->

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

```ini
extension = myapp
```

8. Enjoy.

## examples

See [examples](https://github.com/jmjoy/phper/tree/master/examples).

## License

[Unlicense](LICENSE).
[Unlicense](https://github.com/jmjoy/phper/blob/master/LICENSE).
21 changes: 0 additions & 21 deletions examples/hello-class/Cargo.toml

This file was deleted.

30 changes: 0 additions & 30 deletions examples/hello-class/Makefile.toml

This file was deleted.

3 changes: 0 additions & 3 deletions examples/hello-class/build.rs

This file was deleted.

Loading