Commit Graph

33 Commits

Author SHA1 Message Date
Bradley Schofield
1da812cf78
Add php-scrypt as a example project (#146) 2022-10-01 11:24:19 +13:00
Denzyl Dick
5b001cc717 404 /guide doesn't exists. 2022-08-27 18:05:24 +02:00
David Cole
faa452ecd1
Added tomlrs-php to examples 2022-03-31 01:52:46 +13:00
David Cole
664981f4fb
Windows support (#128)
* 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
2022-03-18 16:36:51 +13:00
Torsten Dittmann
2315fa6bc1
readme: fix link to guide 2021-12-30 14:29:59 +01:00
David Cole
c274417c42
Updated README with new opus-php link 2021-11-24 22:25:17 +13:00
David Cole
c12dde1866
Add feature to convert anyhow errors to PHP exceptions (#110) 2021-11-23 18:03:25 +13:00
David Cole
fa05703c08 Release v0.7.0 2021-11-20 14:33:41 +13:00
David Cole
466c1658e3
Refactor module paths (#101)
* Refactor module layout

* Fixed documentation tests

* Removed skel, moved macro crate

* Ignore folders for crate publish

* Fix builder for zts

* Add `rustfmt.toml`, wrap all comments #96

* Fixed up documentation links, tidied up

* Add `Zend` prefix to callable and hashtable

* Updated guide types

* Updated changelog
2021-10-10 17:51:55 +13:00
David Cole
5bf24588c9 v0.4.0: bump version 2021-09-05 18:46:38 +12:00
David Cole
d2b0418020 Rust highlighting for README example 2021-08-22 02:11:06 +12:00
David Cole
dfee61f969 Run macro doctests, use readme in docs 2021-08-22 02:03:45 +12:00
David Cole
c9feb86901 Added links to guide 2021-08-22 01:18:51 +12:00
David
bd84f28054
Added ext-php-rs guide (#52)
* 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`
2021-08-22 01:00:14 +12:00
David
84aaa07d3e
Add abstraction macros (#49)
* Remove uses of `unwrap`, improve library safety

* Started work on `#[php_function]` attribute

* Added `PhantomData` to `ZendHashTable`

Proper lifetimes for `HashTable` type

* `#[php_function]` now accepts `Vec<T>`

Refactored `ZendHashTable` iterators - there is now `Iter` and
`IntoIter` depending on whether it will consume the HashTable or not.

* Add support for nullable types

* Allow `optional` parameter on attribute

* Support primitive and `Option` return types

* Tidied and refactored attribute

* Added documentation for `#[php_function]`

Implemented `IntoZval` for `Option<T>` when `IntoZval` is also
implemented for `T`. `None` resolves to `null`.

* Added `#[php_method]` attribute

* Added `Callable` type, implemented `Drop` on `Zval`

While implementing `Drop`, the `Copy` derivation was removed, however,
this should not have been there in the first place (`Zval` is not valid
for `Copy` if it contains a string).

* Added some macro functions to example

* Add support for boolean arguments

* Added wrapper around binary data

Future support for binary arguments with `#[php_function]` macros.
Unpacking binary data is no longer unsafe. It was never really unsafe in
the beginning, as we were always reading valid memory, just the contents
of the data could not be trusted.

* Added `#[php_module]` attribute, added support for binary arguments

* Added defaults for functions

* Add defaults for methods

* Add startup function macro and prelude

* Refactored method adding

Now done through impl attribute

* Don't rename functions - generate another internal fn

Also hide all generated functions from docs

* Generate startup function when not already defined

* Add support for class and global constants

* Updated `skel` project

* Updated macro documentation, added executor globals

* Remove `Copy` bound for HashMap to Zval

* Updated documentation

* Add `FromZval` trait, updated docs

* Fixed clippy lints

* Fixed ZTS executor globals

* Fix clippy lint
2021-08-18 13:15:25 +12:00
David
317201bbb9
Update Discord image location 2021-06-10 08:44:42 +12:00
David Cole
f4d0bd7ea9 Updated README 2021-05-21 15:12:35 +12:00
David Cole
5ac8aeecc4 Moved contribution section of README 2021-05-16 15:27:32 +12:00
David
fcdd9332f5
Build and deploy docs to Github pages (#35)
* Added Github action for building and publishing docs

* Create index redirect page for docs

* Only deploy on master, fixed redirect
2021-05-04 11:42:52 +12:00
David
439f2ae981
Relicense under MIT or Apache 2.0 (#27)
* Relicense under MIT or Apache 2.0

* Updated license in README to match Rust guidelines
2021-04-22 20:01:30 +12:00
David Cole
7042018222 Added Clang to requirements 2021-04-20 16:40:35 +12:00
David Cole
75f99c6837 Updated Discord invite to use vanity URL 2021-04-18 17:02:04 +12:00
David Cole
136cc4138d Added opus-php to examples 2021-04-18 17:01:31 +12:00
David
472e26e8fb
Added ability to register constants (#22) 2021-04-18 16:48:58 +12:00
David
3503b10289
Added Discord link to README 2021-04-09 12:36:30 +12:00
David Cole
5f4b3f09f7 Updated README 2021-04-02 18:19:37 +13:00
David Cole
a0e38847b1 Updated README 2021-04-02 18:18:08 +13:00
David Cole
c6aa081a02 Rename crate to ext-php-rs 2021-04-02 18:12:30 +13:00
David
e4deb1f93f
Implemented classes (#17)
* Add PHP thread safety to build matrix

* Revert "Add PHP thread safety to build matrix"

This reverts commit 7de868e6b6e329b87c412af8daf61cba1a3e29c5.

* Fixed arguments not being reconized by PHP

* Added function to create interned Zend string

* Changed statup/shutdown function types to Rust types

Prevents users having to import from bindings

* Added flags for classes

* WIP: class builder

* Added properties to classes

* Added class constants

* Added PHP base extensions
Added class inheritance

* Fixed memory leak with constants

Created C wrapper which is compiled and linked in the `build.rs`
script. In the process removed the `build_id()` function as now
we can just export the macro via a function which is defined in
`wrapper.c`.

* Fixed lint issue

* Added functions to set zval as different strings

Regular strings, persistent strings and interned strings

* Updated README with requirements

* Fixed lint issues

* Changed properties to use proper function

* Free zend string when it is changed for a persistent one

* WIP: overriding zend objects

* Added comments to the top of modules.

* Fixed some comments

* Initialize hash map with initial size when converting from HashMap and
Vec

* Removed unused imports

* WIP: object overrides

* Added DerefMut implementation for ZendClassObject

Tidied up lints that clippy was complaining about, removed debugging
statements.

* Fixed pointer dereference error in macro

* Added missing comments for trait

* All functions now take mutable references vs ptr

Removed SetZval implementation for *mut Zval.
Made bindings public, removed duplicate bindings.
Fixed `create_object` handler not working.
Note to self: smaller commits.

* Showcase ability to use shared object

* WIP: debugging property errors

Changed `function` to `method` in classes
Fixed doctest for `c_str`

* Disabled class properties temporarily

See #16

* Initialize args array with size
2021-04-02 14:18:45 +13:00
David
8f108a61c3
Returning from functions (#9)
* Added ability to set value of zval

This allows the return value to now be set.
See the example in `example/skel/src.lib`.

* Added PHP internals book to resources

* Pass self as pointer to keep consistency
2021-03-11 01:06:58 +13:00
David
9fbe186098
Added argument parsing for functions (#6)
* Moved not required argument logic into function

Seemed more logical, as you can't have a required argument after the
not required argument. Usage:

```rs
FunctionBuilder::new("skeleton_version", skeleton_version)
    .arg(Arg::new("req_arg1", DataType::String))
    .arg(Arg::new("req_arg1", DataType::String))
    .not_required()
    .arg(Arg::new("not_req_arg1", DataType::String))
    .build()
```

* Added zend_value implementation

Helper functions to retrieve the value from zvals

* Started work on argument parser

* Added PHP version support notice

Due to the way the Zend API changes and the fact that the
stable interface is exposed via C macros, there is no
support for versions lower than PHP 8.0. In the future
we can support PHP 7.4 through Rust features.

* Added TryFrom implementations for Zval -> Types

* Added ability to select arguments from ExecutionData

* Added ability to parse arguments and retrieve val

See `example/skel/src/lib.rs` for usage.
2021-03-10 19:50:44 +13:00
David Cole
d964164ca7 added contributing clause 2021-03-09 20:58:07 +13:00
David Cole
a7d542735f added readme, license, updated cargo.toml 2021-03-09 20:56:14 +13:00