Skip to content
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
8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ license = "MIT OR Apache-2.0"
keywords = ["php", "ffi", "zend"]
version = "0.13.1"
authors = ["David Cole <[email protected]>"]
edition = "2018"
edition = "2021"
categories = ["api-bindings"]
exclude = ["/.github", "/.crates", "/guide"]
exclude = ["/.github", "/.crates"]

[dependencies]
bitflags = "2"
Expand Down Expand Up @@ -49,3 +49,7 @@ members = [

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docs"]

[[example]]
name = "hello_world"
crate-type = ["cdylib"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ Contributions welcome include:
When contributing, please keep in mind the following:
- Create tests if possible.
- Update the documentation if necessary.
- If your change is a [braking change](https://semver.org) a migration guide MUST be included. This
should be placed in the `guide/src/migration-guides` directory.
- Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). We use these to automatically generate changelogs.

Unless you explicitly state otherwise, any contribution intentionally submitted
Expand Down
11 changes: 11 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! The build script for ext-php-rs.
//! This script is responsible for generating the bindings to the PHP Zend API.
//! It also checks the PHP version for compatibility with ext-php-rs and sets
//! configuration flags accordingly.
#[cfg_attr(windows, path = "windows_build.rs")]
#[cfg_attr(not(windows), path = "unix_build.rs")]
mod impl_;
Expand All @@ -18,6 +22,7 @@ use impl_::Provider;
const MIN_PHP_API_VER: u32 = 20200930;
const MAX_PHP_API_VER: u32 = 20240924;

/// Provides information about the PHP installation.
pub trait PHPProvider<'a>: Sized {
/// Create a new PHP provider.
fn new(info: &'a PHPInfo) -> Result<Self>;
Expand Down Expand Up @@ -75,9 +80,11 @@ fn find_php() -> Result<PathBuf> {
})
}

/// Output of `php -i`.
pub struct PHPInfo(String);

impl PHPInfo {
/// Get the PHP info.
pub fn get(php: &Path) -> Result<Self> {
let cmd = Command::new(php)
.arg("-i")
Expand All @@ -100,25 +107,29 @@ impl PHPInfo {
.try_into()
}

/// Checks if thread safety is enabled.
pub fn thread_safety(&self) -> Result<bool> {
Ok(self
.get_key("Thread Safety")
.context("Could not find thread safety of PHP")?
== "enabled")
}

/// Checks if PHP was built with debug.
pub fn debug(&self) -> Result<bool> {
Ok(self
.get_key("Debug Build")
.context("Could not find debug build of PHP")?
== "yes")
}

/// Get the php version.
pub fn version(&self) -> Result<&str> {
self.get_key("PHP Version")
.context("Failed to get PHP version")
}

/// Get the zend version.
pub fn zend_version(&self) -> Result<u32> {
self.get_key("PHP API")
.context("Failed to get Zend version")
Expand Down
3 changes: 3 additions & 0 deletions crates/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ quote = "1.0.9"
proc-macro2 = "1.0.26"
lazy_static = "1.4.0"
anyhow = "1.0"

[lints.rust]
missing_docs = "warn"
Loading
Loading