jphp-group / jphp

JPHP - an implementation of PHP on Java VM

Home Page:http://jphp.develnext.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use buffered I/O or constants

danog opened this issue · comments

Cannot open the buffered I/O php://input and php://output constants.
Also, the STDIN, STDOUT and STDERR constants that should set to be already-opened php://stdin, php://stdout, php://stderr streams are just strings.

Code:

<?php

var_dump(\STDIN);
var_dump(\STDOUT);
var_dump(\STDERR);

var_dump(fopen('php://input', 'r'));
var_dump(fopen('php://output', 'w'));

var_dump(fopen('php://stdin', 'r'));
var_dump(fopen('php://stdout', 'w'));
var_dump(fopen('php://stderr', 'w'));

Result:

[daniil@daniil-arch jav]$ jppm start
-> linux
-> app:run 
-> install 
string(5) "STDIN"
string(6) "STDOUT"
string(6) "STDERR"
Warning: fopen(): failed to open stream, null in 'res://7.php' on line 6 at pos 10
bool(false)
Warning: fopen(): failed to open stream, null in 'res://7.php' on line 7 at pos 10
bool(false)
object(php\io\MiscStream)#1031061344 (4) {
  ["path":"php\io\MiscStream":private]=>
  string(5) "stdin"
  ["mode":"php\io\MiscStream":private]=>
  string(1) "r"
  ["path":"php\io\Stream":private]=>
  NULL
  ["mode":"php\io\Stream":private]=>
  NULL
}
object(php\io\MiscStream)#686466458 (4) {
  ["path":"php\io\MiscStream":private]=>
  string(6) "stdout"
  ["mode":"php\io\MiscStream":private]=>
  string(1) "w"
  ["path":"php\io\Stream":private]=>
  NULL
  ["mode":"php\io\Stream":private]=>
  NULL
}
object(php\io\MiscStream)#875016237 (4) {
  ["path":"php\io\MiscStream":private]=>
  string(6) "stderr"
  ["mode":"php\io\MiscStream":private]=>
  string(1) "w"
  ["path":"php\io\Stream":private]=>
  NULL
  ["mode":"php\io\Stream":private]=>
  NULL
}

The buffered I/O streams can just be linked to stdin and stdout, like they normally are on PHP CLI.

Regarding php://input, I don’t really understand how to integrate this into the engine, because jphp does not implement web functionality as in the original php.

Yeah, it's a bit tricky.
You could link it to php://stdin, or to an empty stream like zend PHP does.