Protocols and Wrapper in PHP
Last Updated :
16 Jan, 2022
There are various inbuilt wrapper for a different type of URL- style protocols in PHP. These wrappers are used in many other file system functions. Registration of custom wrapper is also allowed in PHP. It can be done so through stream_wrapper_register() function.
In PHP the URL syntax supported is scheme://
The URL syntax not supported in PHP are:
There are 12 wrapper in PHP.
Wrapper |
Work |
Description |
file:// |
Local file system is accessed through it |
This default wrapper in PHP is representing local file system. |
http:// |
HTTP(s) URLs is accessed through it |
The mentioned relative path is applied against present working directory. |
ftp:// |
FTP(s) URLs is accessed through it |
New files are created and earlier ones are accessed through FTP. If passive mode FTP is not supported by the server then there is a fail in connection. |
php:// |
Multiple type of I/O streams is accessed through it |
I/O error file descriptors, streams, inmemory can be read and written through other I/O streams. |
zlib:// |
Streams are compressed |
Works in a similar manner as gzopen(), except the fact that other file system functions can be used with it. |
data:// |
Data (RFC 2397) |
Reading contents or media type which can be later printed. |
glob:// |
Finding pathnames such that it matches the pattern |
The most common use includes searching over the directory and printing a file’s name and size. |
phar:// |
Archive in PHP |
Read and write can be performed individually as well as simultaneously but cannot be appended. |
ssh2:// |
Shell 2 is secured |
This wrapper is not available by default in PHP, for accessing it SSH2 extension needs to be downloaded. |
rar:// |
RAR |
The URL path(encoded) is taken to RAR archive where RAR can be relative or absolute. Other optional things that are stored in archive are – asterik(*), number sign(#) and entry name. Both directories and files are accessible through it. |
ogg:// |
Audio stream |
The ogg:// wrapper opens the file that are compressed audio that have been encoded through OGG/Vorbis codec. Even if the files are appended they are compressed audio. This wrapper is not available by default in PHP, for accessing it OGG/Vorbis extension needs to be downloaded. |
expect:// |
Interaction streams are processed |
This wrapper makes stderr, process’es stdio and stdout accessible. This wrapper is not available by default in PHP, for accessing it Expect extension needs to be downloaded. |
Share your thoughts in the comments
Please Login to comment...