PhpStreamWrapperInterface
interface PhpStreamWrapperInterface (View source)
Defines a generic PHP stream wrapper interface.
Methods
Close directory handle.
Open directory handle.
Read entry from directory handle.
Rewind directory handle.
Create a directory.
Renames a file or directory.
Removes a directory.
Retrieve the underlying stream resource.
Closes stream.
Tests for end-of-file on a file pointer.
Flushes the output.
Advisory file locking.
Sets metadata on the stream.
Opens file or URL.
Read from stream.
Seeks to specific location in a stream.
Change stream options.
Retrieve information about a file resource.
Retrieve the current position of a stream.
Truncate stream.
Write to stream.
Delete a file.
Retrieve information about a file.
Details
bool
dir_closedir()
Close directory handle.
This method is called in response to closedir(). Any resources which were locked, or allocated, during opening and use of the directory stream should be released.
bool
dir_opendir(string $path, int $options)
Open directory handle.
This method is called in response to opendir().
string|false
dir_readdir()
Read entry from directory handle.
This method is called in response to readdir().
bool
dir_rewinddir()
Rewind directory handle.
This method is called in response to rewinddir(). Should reset the output generated by PhpStreamWrapperInterface::dir_readdir. The next call to PhpStreamWrapperInterface::dir_readdir should return the first entry in the location returned by PhpStreamWrapperInterface::dir_opendir.
bool
mkdir(string $path, int $mode, int $options)
Create a directory.
This method is called in response to mkdir()
Note, in order for the appropriate error message to be returned this method should not be defined if the wrapper does not support creating directories.
Note, the streamWrapper::$context property is updated if a valid context is passed to the caller function.
bool
rename(string $path_from, string $path_to)
Renames a file or directory.
This method is called in response to rename(). Should attempt to rename $path_from to $path_to.
Note, in order for the appropriate error message to be returned this method should not be defined if the wrapper does not support renaming files.
Note, the streamWrapper::$context property is updated if a valid context is passed to the caller function.
bool
rmdir(string $path, int $options)
Removes a directory.
This method is called in response to rmdir().
Note, in order for the appropriate error message to be returned this method should not be defined if the wrapper does not support removing directories.
Note, the streamWrapper::$context property is updated if a valid context is passed to the caller function.
resource|false
stream_cast(int $cast_as)
Retrieve the underlying stream resource.
This method is called in response to stream_select().
stream_close()
Closes stream.
This method is called in response to fclose(). All resources that were locked, or allocated, by the wrapper should be released.
bool
stream_eof()
Tests for end-of-file on a file pointer.
This method is called in response to feof().
Warning, when reading the whole file (for example, with file_get_contents()), PHP will call PhpStreamWrapperInterface::stream_read() followed by PhpStreamWrapperInterface::stream_eof() in a loop but as long as PhpStreamWrapperInterface::stream_read() returns a non-empty string, the return value of PhpStreamWrapperInterface::stream_eof() is ignored.
bool
stream_flush()
Flushes the output.
This method is called in response to fflush() and when the stream is being closed while any un-flushed data has been written to it before. If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now.
Note, if not implemented, FALSE is assumed as the return value.
bool
stream_lock(int $operation)
Advisory file locking.
This method is called in response to flock(), when file_put_contents() (when flags contains LOCK_EX), stream_set_blocking() and when closing the stream (LOCK_UN).
bool
stream_metadata(string $path, int $option, mixed $value)
Sets metadata on the stream.
bool
stream_open(string $path, string $mode, int $options, string $opened_path)
Opens file or URL.
This method is called immediately after the wrapper is initialized (e.g. by fopen() and file_get_contents()).
Note the streamWrapper::$context property is updated if a valid context is passed to the caller function.
string|false
stream_read(int $count)
Read from stream.
This method is called in response to fread() and fgets().
Note, remember to update the read/write position of the stream (by the number of bytes that were successfully read).
Note, PhpStreamWrapperInterface::stream_eof() is called directly after calling PhpStreamWrapperInterface::stream_read() to check if EOF has been reached. If not implemented, EOF is assumed.
Warning, when reading the whole file (e.g., with file_get_contents()), PHP will call PhpStreamWrapperInterface::stream_read() followed by PhpStreamWrapperInterface::stream_eof() in a loop but as long as PhpStreamWrapperInterface::stream_read() returns a non-empty string, the return value of PhpStreamWrapperInterface::stream_eof() is ignored.
bool
stream_seek(int $offset, int $whence = SEEK_SET)
Seeks to specific location in a stream.
This method is called in response to fseek().
The read/write position of the stream should be updated according to the offset and whence.
bool
stream_set_option(int $option, int $arg1, int $arg2)
Change stream options.
This method is called to set options on the stream.
array|false
stream_stat()
Retrieve information about a file resource.
This method is called in response to fstat().
int
stream_tell()
Retrieve the current position of a stream.
This method is called in response to fseek() to determine the current position.
bool
stream_truncate(int $new_size)
Truncate stream.
Will respond to truncation; e.g., through ftruncate().
int
stream_write(string $data)
Write to stream.
This method is called in response to fwrite(). Remember to update the current position of the stream by number of bytes that were successfully written.
bool
unlink(string $path)
Delete a file.
This method is called in response to unlink().
Note, in order for the appropriate error message to be returned this method should not be defined if the wrapper does not support removing files.
Note, the streamWrapper::$context property is updated if a valid context is passed to the caller function.
array|false
url_stat(string $path, int $flags)
Retrieve information about a file.
This method is called in response to all stat() related functions.
Note, the streamWrapper::$context property is updated if a valid context is passed to the caller function.