File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,37 @@ provide interoperability between PHP and JavaScript code.
8
8
9
9
# USAGE
10
10
11
+ ``` js
12
+ var path = require (' path' );
13
+ var php = require (' php-embed' );
14
+ php .request ({
15
+ file: path .join (__dirname , ' hello.php' ),
16
+ stream: process .stdout
17
+ }).then (function (v ) {
18
+ console .log (' php is done and stream flushed.' );
19
+ });
20
+ ```
21
+
11
22
# API
12
23
24
+ ## php.request(options, [ callback] )
25
+ Triggers a PHP "request", and returns a ` Promise ` which will be
26
+ resolved when the request completes. If you prefer to use callbacks,
27
+ you can ignore the return value and pass a callback as the second
28
+ parameter.
29
+ * ` options ` : a hash containing various parameters for the request.
30
+ Either ` source ` or ` file ` is mandatory; the rest are optional.
31
+ - ` source ` :
32
+ Specifies a source string to evaluate in the request context.
33
+ - ` file ` :
34
+ Specifies a PHP file to evaluate in the request context.
35
+ - ` stream ` :
36
+ A node ` stream.Writable ` to accept output from the PHP request.
37
+ If not specified, defaults to ` process.stdout ` .
38
+ * ` callback ` * (optional)* : A standard node callback. The first argument
39
+ is non-null if an exception was raised. The second argument is the
40
+ result of the PHP evaluation, converted to a string.
41
+
13
42
# INSTALLING
14
43
15
44
You can use [ ` npm ` ] ( https://github.com/isaacs/npm ) to download and install:
You can’t perform that action at this time.
0 commit comments