Closes https://github.com/davidcole1340/ext-php-rs/issues/208
Closes https://github.com/davidcole1340/ext-php-rs/issues/209
## Summary of the changes
### Build scripts
* the `unix_build.rs` script now honors the `PHP_CONFIG` environment variable, like `cargo php install`
* use `cargo:rerun-if-env-changed` for the `PHP`, `PHP_CONFIG` and `PATH` environment variables, to avoid needless recompilation of the whole dependency tree.
### Documentation
While trying to document the aforementioned changes, I realized that there was no chapter about installing and setting up a PHP environment to develop PHP extensions. So, I refactored the first chapters of the book into a `Getting Started` section, including instructions on how to quickly set up a PHP environment.
* Allow passing `--yes` parameter to bypass prompts
Makes this tool usable in automated builds such as Docker containers.
Addresses https://github.com/davidcole1340/ext-php-rs/issues/133
* Update readme and guides
* rustfmt
Co-authored-by: David Cole <david.cole1340@gmail.com>
* Preliminary Windows support
* Start work on cross-platform build script
* Fix compilation on macOS
* Updated README, tidied up build script
* Check linker version before starting compilation
It doesn't seem like it's possible to change the linker from within the
build script, however, we can retrieve the linker in use and give the
user a suggestion if the linker will not work.
* Switch to using Github repository for bindgen
* Split Windows and Unix implementations into two files
* Fix building on Windows
* Remove `reqwest` and `zip` as dependencies on Unix
* Fix guide tests on Windows
* Started work on Windows CI
* runs -> run
* Use preinstalled LLVM on Windows
* Debugging for Windows CI
* Switch to upstream `rust-bindgen` master branch
* Switch to `rust-lld` for Windows linking
* Don't compile `cargo-php` on Windows
* Switch to using skeptic for tests
* cargo-php: Disable stub generation, fix ext install/remove
The plan is to replace the stub generation by generating them with PHP
code. This is cross-platform and means we don't need to worry about ABI.
We also don't need to embed information into the library.
* cargo-php: Fix on unix OS
* Fix clippy lint
* Updated README
* Re-add CI for Unix + PHP 8.0
* Fix building on thread-safe PHP
* Tidy up build scripts
* Use dynamic lookup on Linux, test with TS Windows
* Define `ZTS` when compiling PHP ZTS
* Combine Windows and Unix CI, fix linking for Win32TS
* Fix exclusions in build CI
* rust-toolchain -> rust
* Set LLVM version
* Only build docs.rs on Ubuntu PHP 8.1
* Fix build on Linux thread-safe
* Update guide example
* started work on stub generator
* Worked on stub CLI tool
* Unused import
* Account for namespaces in function and class names
* Add support for docblocks on structs
* Push Rust comments to stubs
* Add indentation to stub generation
* Add CLI application to install and generate stubs
This time CLI application is defined on user side, called with `cargo
run -- ..args..`
* Export anyhow result
* Add constants to stub file
* Removed stub symbols
No longer required as we are now building while also linking to PHP.
Keeping the stubs causes the stubs to override the real symbols in the
extension.
* Fix stubs for real this time
Removed stub symbols as they were being included in the extension
dylib, fix by loading the PHP executable as a dylib, loading the
required symbols globally.
* Maybe actually fix stubs this time
* Forgot to remove PHP binary loading
* let's give this another go... cargo subcommand
Now called via `cargo php <install,stubs>`.
* Added `remove` command
* Tidied up cargo-php, commented, set up CI
* Fix return types with non-ident types
* define namespace ordering
* Fix tests, replace `Self` when in outer context
* Moved allowed bindings into separate file
* Update guide with CLI instructions
* Remove lifetime from `PhpException`
All class entries are effectively static (module start to module end) so
it's just a hassle carrying the lifetime everywhere.
* Removed forgotten lifetimes
* Implement `IntoZval` for `Result<T, E>`
Fixes function return error with `PhpResult` as the return type
* Updated changelog
* Rough implementation of struct properties
* Store properties hashtable once
* Tidy up handler functions with exceptions
* Add stub `get_properties` function for codegen structs
* Remove nightly features
* Revert storing properties
Technically, the zend object _could_ move in memory, leaving dangling
references in the properties hashtable. We will just build the hashtable
when required.
* Added `#[prop]` attribute
* Add pointer type to zval, tidy up zend string
* Add support for method properties
* Add `#[getter]` and `#[setter]` attributes
* Update documentation with method properties
* Tidy up macros code
* Remove string gc checks (done on PHP side)
* Move `RegisteredClass` implementation to module, update docs
* Fix read property `rv` segfault
* Fixed doctests
* Start work on returning new objects
Change `IntoZval` to consume `self`
* Add conversion from vector reference to PHP hashtable through clones
* `set_binary` now only takes `Vec`
Used to take `AsRef<[T]>` to allow users to pass arrays, however, this
causes the data to be cloned even if the user passes a `Vec`.
* Rename `as_zval` to `into_zval` to match Rust conventions
* Started work on closures
* Finish implementation of closures
* Document closures, add to prelude, feature gate
* Fixed closure example
* Panic instead of return result when adding property
This will almost always be unwrapped
* Remove unused `set_refcount` function
Wasn't valid either way
* Add ability to get and set properties on class objects
* Updated documentation adding properties
* Allow returning of object references
`TYPE` is now also on `IntoZval` which means `FromZval` does not need to
be implemented on return types
* Clippy lints
* Replace `ZendObjectOverride` derive macro with `#[php_class]`
* Updated guide with `#[php_class]` macro
* Panic rather than return error when implementing interface
It's gonna panic either way so might as well make it easier for the
builder
* Remove `libc` dependency
* Started work on guide, added types
* Rewrite argument parser to allow referencs
Primarly so that `&str` is a valid parameter type.
* Remove generic `Into<String>` conversion to exception
* Worked on guide, added macros
* Build guide when building docs
* Allow manual trigger of docs build
* `cargo fmt`