Returning Streams from your own PHP_FUNCTION()s is easy too:

 1: PHP_FUNCTION(example_open)
 2: {
 3:     php_stream *stream;
 4: 
 5:     if (ZEND_NUM_ARGS() != 0) {
 6:         WRONG_PARAM_COUNT;
 7:     }
 8:     
 9:     stream = php_stream_open_wrapper(
10:         "http://www.php.net",
11:         "rb", REPORT_ERRORS, NULL);
12: 
13:     php_stream_to_zval(stream, return_value);
14: 
15: }