The streamWrapper class

(PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8)

Introduction

Allows you to implement your own protocol handlers and streams for use with all the other filesystem functions (such as fopen(), fread() etc.).

Note:

This is NOT a real class, only a prototype of how a class defining its own protocol should be.

Note:

Implementing the methods in other ways than described here can lead to undefined behaviour.

An instance of this class is initialized as soon as a stream function tries to access the protocol it is associated with.

Class synopsis

classstreamWrapper {
public__construct()
publicdir_opendir(string$path, int$options): bool
publicmkdir(string$path, int$mode, int$options): bool
publicrename(string$path_from, string$path_to): bool
publicrmdir(string$path, int$options): bool
publicstream_cast(int$cast_as): resource
publicstream_eof(): bool
publicstream_lock(int$operation): bool
publicstream_metadata(string$path, int$option, mixed$value): bool
publicstream_open(
    string$path,
    string$mode,
    int$options,
    ?string&$opened_path
): bool
publicstream_read(int$count): string|false
publicstream_seek(int$offset, int$whence = SEEK_SET): bool
publicstream_set_option(int$option, int$arg1, int$arg2): bool
publicstream_tell(): int
publicstream_truncate(int$new_size): bool
publicstream_write(string$data): int
publicunlink(string$path): bool
publicurl_stat(string$path, int$flags): array|false
public__destruct()
}

Properties

resource context

The current context, or null if no context was passed to the caller function.

Use the stream_context_get_options() to parse the context.

Note:

This property must be public so PHP can populate it with the actual context resource.

Table of Contents

To Top