2019/05/18
mkdir work
cd work
git clone https://github.com/php/php-src.git
cd php-src
git checkout PHP-7.4
./configure --with-ffi
make
cd ..
git clone https://github.com/nishimura/php_ffi_samples.git
cd php_ffi_samples
../php-src/sapi/cli/php -d ffi.enable=1 -S localhost:8000
# and access to
# http://localhost:8080/
# http://localhost:8080/1/
# ...
require: c build tools
cd 2
make
# and access to
# http://localhost:8080/2/
- 3: call with closure argument
- 4: c struct, php reference and callback
- 5: FFI bridge
- 6, 7: call haskell functions directly
require: haskell build tools (ghc)
PHP => FFI C => FFI Haskell => Callback C => Callback PHP => Set c variable instead of return value
PHP => FFI Haskell Callback PHP => Set haskell IORef instead of return value