Skip to main content

Crate ext_php_rs_build

Crate ext_php_rs_build 

Source
Expand description

Build-time PHP detection utilities for ext-php-rs.

This crate provides utilities for detecting PHP installations and version information at build time. It is used by ext-php-rs’s build script and can be used by other crates that need to detect PHP at compile time.

§Example

use ext_php_rs_build::{find_php, PHPInfo, ApiVersion};

fn main() -> anyhow::Result<()> {
    let php = find_php()?;
    let info = PHPInfo::get(&php)?;
    let version: ApiVersion = info.zend_version()?.try_into()?;

    for api in version.supported_apis() {
        println!("cargo:rustc-cfg={}", api.cfg_name());
    }
    Ok(())
}

Structs§

PHPInfo
Output of php -i.

Enums§

ApiVersion
PHP API version enum.

Functions§

emit_check_cfg
Emits the cargo check-cfg directive for all PHP version flags.
emit_php_cfg_flags
Emits cargo cfg flags for the detected PHP version.
emit_rerun_if_env_changed
Emits cargo rerun-if-env-changed for PHP-related environment variables.
find_executable
Finds the location of an executable name.
find_php
Finds the location of the PHP executable.
path_from_env
Returns an environment variable’s value as a PathBuf.