Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

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:

  • scheme:/
  • scheme:

There are 12 wrapper in PHP.

file://Local file system is accessed through itThis default wrapper in PHP is representing local file system. 
http://HTTP(s) URLs is accessed through itThe mentioned relative path is applied against present working directory.
ftp://FTP(s) URLs is accessed through itNew 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 itI/O error file descriptors, streams, inmemory can be read and written through other I/O streams. 
zlib://Streams are compressedWorks 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 patternThe most common use includes searching over the directory and printing a file’s name and size.
phar:// Archive in PHPRead and write can be performed individually as well as simultaneously but cannot be appended.
ssh2://Shell 2 is securedThis wrapper is not available by default in PHP, for accessing it  SSH2 extension needs to be downloaded.
rar://RARThe 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.  

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!