diff --git a/build.rs b/build.rs index 25461ae580..4249964936 100644 --- a/build.rs +++ b/build.rs @@ -209,6 +209,16 @@ fn generate_bindings(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result Result<()> { ] { println!("cargo:rerun-if-changed={}", path.to_string_lossy()); } - for env_var in ["PHP", "PHP_CONFIG", "PATH"] { + for env_var in ["PHP", "PHP_CONFIG", "PATH", "EXT_PHP_RS_ALLOWED_BINDINGS"] { println!("cargo:rerun-if-env-changed={env_var}"); } diff --git a/guide/src/SUMMARY.md b/guide/src/SUMMARY.md index 615c9a5bb3..333504056c 100644 --- a/guide/src/SUMMARY.md +++ b/guide/src/SUMMARY.md @@ -38,6 +38,7 @@ # Advanced Topics - [Async](./advanced/async_impl.md) +- [Allowed Bindings](./advanced/allowed_bindings.md) # Migration Guides --- diff --git a/guide/src/advanced/allowed_bindings.md b/guide/src/advanced/allowed_bindings.md new file mode 100644 index 0000000000..a6fea6a1d5 --- /dev/null +++ b/guide/src/advanced/allowed_bindings.md @@ -0,0 +1,27 @@ +# Allowed Bindings + +The extension limits the bindings that are generated by `bindgen` to a subset of the original bindings. +Those bindings are defined in the `allowed_bindings.rs` file. + +Should you need to add more bindings, you can do so by defining them as a comma-separated list in the `EXT_PHP_RS_ALLOWED_BINDINGS` environment variable. + +This can be configured in your `.cargo/config.toml` file: + +```toml +[env] +EXT_PHP_RS_ALLOWED_BINDINGS = "php_foo,php_bar" +``` + +Your bindings should now appear in the `ext_php_rs::ffi` module. + +
+Pay attention to the PHP version + +Be aware, that bindings that do not exist in the PHP version you are targeting will not be available. + +Some bindings may also change between PHP versions, so make sure to test your extension with all PHP versions you are targeting. +
+ +## Contributing + +If you think that a binding should be added to the allowed bindings, please open an issue or a pull request on the [GitHub repository](https://github.com/davidcole1340/ext-php-rs) so that everyone can benefit from it.