Open liudonghua123 opened 9 months ago
The php-cgi
CLI will need the -f
option before the filename. This should work.
wasmer php-cgi-8.2.6.wasm --dir . -f hello.php
We only offer the full PHP interpreter flavored for WasmEdge as we've based it's socket implementation on top of WasmEdge sockets. We did not find it useful (at this time) to invest into cutting all the socket-related code from the php
CLI and offering a version with that. php-cgi
seemed enough for most use-cases, as it is what runs in most traditional deployments.
Let me know if the above line fixes your use-case. If that's so I would close the issue for now.
@assambar Thanks, now I see some difference about php-cgi
and php
.
I tried wasmer php-cgi-8.2.6.wasm --dir . -f hello.php
, but it did not work for me, I still could not use wasmer/wasmedge php-cgi
to run an echo hellworld
example.
Did I miss something? It seemed I could not pass hello.php
to php-cgi
.
And another question, why php
cli needs socket
while php-cgi
does not?
> wasmer run php-cgi-8.2.6.wasm --dir . -- -f hello.php
No input file specified.
> wasmedge run --dir . php-cgi-8.2.6.wasm -- -f hello.php
Status: 404 Not Found
X-Powered-By: PHP/8.2.6
Content-type: text/html; charset=UTF-8
No input file specified.
> wasmedge run --dir . php-cgi-8.2.6.wasm -- hello.php
X-Powered-By: PHP/8.2.6
Content-type: text/html; charset=UTF-8
> wasmer run php-cgi-8.2.6.wasm --dir . -- -h
Usage: php-cgi [-q] [-h] [-s] [-v] [-i] [-f <file>]
php-cgi <file> [args...]
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
-T <count> Measure execution time of script repeated <count> times.
>
> php hello.php
Hello World
> php-cgi hello.php
X-Powered-By: PHP/8.2.12
Content-type: text/html; charset=UTF-8
Hello World
> php-cgi not-exists.php in cmd at 22:48:32
Status: 404 Not Found
X-Powered-By: PHP/8.2.12
Content-type: text/html; charset=UTF-8
No input file specified.
> php-cgi -h
Usage: php-cgi [-q] [-h] [-s] [-v] [-i] [-f <file>]
php-cgi <file> [args...]
-a Run interactively
-b <address:port>|<port> Bind Path for external FASTCGI Server mode
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
-T <count> Measure execution time of script repeated <count> times.
>
It's really strange, I can pass the file to python-3.11.4.wasm. But the same method did not work for php-cgi-8.2.6.wasm.
I can use pipe stdin to make it work.
> wasmer run --dir . python-3.11.4.wasm hello.py
Hello World
> wasmer run --dir . php-cgi-8.2.6.wasm hello.php
Status: 404 Not Found
X-Powered-By: PHP/8.2.6
Content-type: text/html; charset=UTF-8
No input file specified.
> cat hello.php | wasmer run --dir . php-cgi-8.2.6.wasm
X-Powered-By: PHP/8.2.6
Content-type: text/html; charset=UTF-8
Hello World
> cat hello.php | php-cgi
X-Powered-By: PHP/8.2.12
Content-type: text/html; charset=UTF-8
Hello World
> php-cgi hello.php
X-Powered-By: PHP/8.2.12
Content-type: text/html; charset=UTF-8
Hello World
> cat hello.py | python
Hello World
> cat hello.py | wasmer run --dir . python-3.11.4.wasm
⠁ Initializing the WebAssembly VM
⠁ Loading from "python-3.11.4.wasm"
⠁ Compiling to WebAssembly
⠉ Compiling to WebAssembly
Python 3.11.4 (tags/v3.11.4:d2340ef, Jul 14 2023, 11:21:53) [Clang 16.0.0 ] on wasi
Type "help", "copyright", "credits" or "license" for more information.
>>> Hello World
>>>
>
Is your feature request related to a problem? Please describe.
Hi, I tried the wasm build of python, ruby and php with my wasmer runtime,
python
andruby
are good, but thePHP
only provide wasmedge version which could not run under the latest wasmer v4.2.3.Can we build the normal or general PHP wasm?
Describe the solution you'd like
Build normal or general PHP wasm like python and ruby.
Describe alternatives you've considered
N.A.
Additional context
N.A.