Skip to content

Missing streams - Cannot read from STDIN ??? #1065

Open
@henrywood

Description

@henrywood

The php streams:

php://memory
php://temp
php://input
php://output

are all missing !

I tried to compile this simple script:

<?php

$input = fopen('php://input', 'rb');
$output = fopen('php://output', 'wb');
$temp = fopen('php://temp', 'wb');

echo "OUTPUT:".PHP_EOL;
fwrite($output, 'HELLO');

$contents = '';

while(! feof($input)) {
        $contents.= fread($input, 8192);
}

echo "Input: ".$contents.PHP_EOL;

I compiles fine with:

kphp test2.php --mode cli --composer-root $(pwd) -o ./test2

But when run output is:

henrik@HSLAPTOP-ASUS:/tmp/sreq2$ ./test2
[1779467][2024-08-14 19:21:12.592479 limits.cpp  124] failed to set rlimit for core dump size.
[1723656072] [1779467] Warning: php://input should be opened in read mode
------- Stack Backtrace -------
(0) ./test2 : php_warning(char const*, ...)+0xa4 [0x6660e4]
(1) ./test2 : f$fopen(string const&, string const&)+0x98 [0x6936e8]
(2) ./test2 : f$src_test2e0546a04c0b99c86()+0x50 [0x521720]
(3) ./test2 : f$src_test2e0546a04c0b99c86$run()+0xd [0x52150d]
(4) ./test2 : PhpScript::run()+0xef [0x71e22f]
(5) /lib/x86_64-linux-gnu/libc.so.6 : +0x5a130 [0x7f00347c5130]
-------------------------------

[1723656072] [1779467] Warning: Stream php://output not found
------- Stack Backtrace -------
(0) ./test2 : php_warning(char const*, ...)+0xa4 [0x6660e4]
(1) ./test2 : f$fopen(string const&, string const&)+0x98 [0x6936e8]
(2) ./test2 : f$src_test2e0546a04c0b99c86()+0xac [0x52177c]
(3) ./test2 : f$src_test2e0546a04c0b99c86$run()+0xd [0x52150d]
(4) ./test2 : PhpScript::run()+0xef [0x71e22f]
(5) /lib/x86_64-linux-gnu/libc.so.6 : +0x5a130 [0x7f00347c5130]
-------------------------------

[1723656072] [1779467] Warning: Stream php://temp not found
------- Stack Backtrace -------
(0) ./test2 : php_warning(char const*, ...)+0xa4 [0x6660e4]
(1) ./test2 : f$fopen(string const&, string const&)+0x98 [0x6936e8]
(2) ./test2 : f$src_test2e0546a04c0b99c86()+0x101 [0x5217d1]
(3) ./test2 : f$src_test2e0546a04c0b99c86$run()+0xd [0x52150d]
(4) ./test2 : PhpScript::run()+0xef [0x71e22f]
(5) /lib/x86_64-linux-gnu/libc.so.6 : +0x5a130 [0x7f00347c5130]
-------------------------------

OUTPUT:
[1723656072] [1779467] Warning: Can't find appropriate wrapper for ""
------- Stack Backtrace -------
(0) ./test2 : php_warning(char const*, ...)+0xa4 [0x6660e4]
(1) ./test2 : f$fwrite(mixed const&, string const&)+0x89 [0x690519]
(2) ./test2 : f$src_test2e0546a04c0b99c86()+0x171 [0x521841]
(3) ./test2 : f$src_test2e0546a04c0b99c86$run()+0xd [0x52150d]
(4) ./test2 : PhpScript::run()+0xef [0x71e22f]
(5) /lib/x86_64-linux-gnu/libc.so.6 : +0x5a130 [0x7f00347c5130]
-------------------------------

[1723656072] [1779467] Warning: Can't find appropriate wrapper for ""
------- Stack Backtrace -------
(0) ./test2 : php_warning(char const*, ...)+0xa4 [0x6660e4]
(1) ./test2 : f$feof(mixed const&)+0x1d0 [0x68ed30]
(2) ./test2 : f$src_test2e0546a04c0b99c86()+0x24c [0x52191c]
(3) ./test2 : f$src_test2e0546a04c0b99c86$run()+0xd [0x52150d]
(4) ./test2 : PhpScript::run()+0xef [0x71e22f]
(5) /lib/x86_64-linux-gnu/libc.so.6 : +0x5a130 [0x7f00347c5130]
-------------------------------

Input:

Also:

stream_copy_to_stream() is missing
stream_get_meta_data() is missing
stream_get_contents() is missing

Can the missing streams ('php://temp', 'php://memory', 'php://input' and 'php://output') be added soon ?

I just spent a couple of days making a PSR-7 HTTP Message implementation to use with KPHP and it compiles fine but does not work due to the missing streams ???

Please prioritize this !

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions