@@ -12,6 +12,11 @@ Export a simple function `function hello_world(string $name): string` to PHP:
1212``` rust
1313use ext_php_rs :: prelude :: * ;
1414
15+ /// Gives you a nice greeting!
16+ ///
17+ /// @param string $name Your name.
18+ ///
19+ /// @return string Nice greeting!
1520#[php_function]
1621pub fn hello_world (name : String ) -> String {
1722 format! (" Hello, {}!" , name )
@@ -24,6 +29,37 @@ pub fn module(module: ModuleBuilder) -> ModuleBuilder {
2429}
2530```
2631
32+ Use [ ` cargo-php ` ] to build IDE stubs and install the extension:
33+
34+ ``` text
35+ $ cargo install cargo-php
36+ Installing cargo-php v0.1.0
37+ $ cargo php stubs --stdout
38+ Compiling example-ext v0.1.0
39+ Finished dev [unoptimized + debuginfo] target(s) in 3.57s
40+ <?php
41+
42+ // Stubs for example-ext
43+
44+ /**
45+ * Gives you a nice greeting!
46+ *
47+ * @param string $name Your name.
48+ *
49+ * @return string Nice greeting!
50+ */
51+ function hello_world(string $name): string {}
52+ $ cargo php install --release
53+ Compiling example-ext v0.1.0
54+ Finished release [optimized] target(s) in 1.68s
55+ Are you sure you want to install the extension `example-ext`? yes
56+ $ php -m
57+ [PHP Modules]
58+ // ...
59+ example-ext
60+ // ...
61+ ```
62+
2763Calling the function from PHP:
2864
2965``` php
@@ -33,6 +69,8 @@ var_dump(hello_world("David")); // string(13) "Hello, David!"
3369For more examples read the library
3470[ guide] ( https://davidcole1340.github.io/ext-php-rs/guide ) .
3571
72+ [ `cargo-php` ] : https://crates.io/crates/cargo-php
73+
3674## Features
3775
3876- ** Easy to use:** The built-in macros can abstract away the need to interact
0 commit comments