-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# hello module | ||
|
||
this module will run `id` command by calling `hello_world()` function. | ||
|
||
Caution: different php api version may cause module loading error. | ||
|
||
## how to build | ||
|
||
- phpize | ||
- ./configure | ||
- make | ||
|
||
## example | ||
|
||
- `/build/hello.so` | ||
- php 7.2 | ||
- x64 elf | ||
- PHP Api Version: 20170718 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dnl Tell PHP about the argument to enable the hello extension | ||
|
||
PHP_ARG_ENABLE(hello, Whether to enable the hello world extension, [ --enable-hello Enable hello world]) | ||
|
||
if test "$PHP_HELLO" != "no"; then | ||
PHP_NEW_EXTENSION(hello, src/hello.c, $ext_shared) | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <php.h> | ||
#include "hello.h" | ||
|
||
zend_function_entry hello_functions[] = { | ||
PHP_FE(hello_world, NULL) | ||
PHP_FE_END | ||
}; | ||
|
||
zend_module_entry hello_module_entry = { | ||
STANDARD_MODULE_HEADER, | ||
PHP_HELLO_EXTNAME, | ||
hello_functions, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
PHP_HELLO_VERSION, | ||
STANDARD_MODULE_PROPERTIES, | ||
}; | ||
|
||
ZEND_GET_MODULE(hello); | ||
|
||
PHP_FUNCTION(hello_world) { | ||
int ret, mode = 1; | ||
char *cmd = "id"; | ||
ret = php_exec(mode, cmd, NULL, return_value); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#define PHP_HELLO_EXTNAME "hello" | ||
#define PHP_HELLO_VERSION "0.0.1" | ||
|
||
PHP_FUNCTION(hello_world); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters