konstantin-kuklin / stream-library
Wrapper for stream functions
Installs: 880
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
Type:php-library
Requires
- php: >=5.3.2
- respect/validation: ^1.1.15
Requires (Dev)
- phpunit/phpunit: ^4.8.35
This package is not auto-updated.
Last update: 2024-11-03 08:48:54 UTC
README
README
What is StreamLibrary?
StreamLibrary is a PHP wrapper via stream functions. It allows to work with streams with more comfortable environment.
Requirements
StreamLibrary is only supported on PHP 5 and up.
Installation
The best way to install StreamLibrary is with composer:
composer.phar require konstantin-kuklin/stream-library:dev-master
Documentation
First step to work is a creating object of Stream:
$stream = new \Stream\Stream($path, $protocol, $port, $driver);
path - Path to file on system or ip address in network or hostname which we will work
protocol - String value of protocol type, can be Connection::PROTOCOL_TCP, Connection::PROTOCOL_UDP, Connection::PROTOCOL_UNIX
port - Integer value of port to connect. Not needs if protocol Connection::PROTOCOL_UNIX. Default value = 0.
driver - Object implements StreamDriverInterface. If your connection need to change transfer data you need to describe it logic with this object. Default value is null(mean data haven't been changed)
Get data from Stream
$stream = new \Stream\Stream($path, $protocol, $port, $driver); $stream->setReceiveMethod(new StreamGetContentsMethod($maxLength, $offset)); $stream->getContents();
maxLength - The maximum bytes to read. Default value is -1 (read all the remaining buffer)
offset - Seek to the specified offset before reading. Default value is -1 (read without offset)
Send data to Stream
$stream = new \Stream\Stream($path, $protocol, $port, $driver); $stream->sendContents($contents);
contents - can contain any string data