2017 © Pedro Peláez
 

library virtual-stream

A Virtual Stream Wrapper

image

pcelta/virtual-stream

A Virtual Stream Wrapper

  • Sunday, August 20, 2017
  • by pcelta
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads License, (*1)

virtual-stream

The Virtual Stream will help you to avoid saving files into filesystem. This is very useful when we're transferring files and testing., (*2)

Instalation

{
    "require": {
        "pcelta/virtual-stream": "dev-master"
    }
}

How to use it

This library implements StreamWrapper class definition exactly as shown here: http://php.net/manual/en/class.streamwrapper.php., (*3)

Basically, this class implements all methods needed to avoid calls to filesystem. For example, in this scenario below you can see many function handling a file resource., (*4)


$filename = __DIR__ . '/dummy.txt'; $resource = fopen($filename, 'w+'); fwrite($resource, 'first'); fwrite($resource, 'second,'); $result = fread($resource, 20); fclose($resource);

To make sure this example will work you need to give permission on current directory for writing and reading because PHP is going to write it., (*5)

That could be avoided using Virtual Stream!, (*6)

Let's have a look at same example above but right now it is using Virtual Stream., (*7)


Stream::register(); // register a new StreamWrapper $filename = sprintf('%s://dummy.txt', Stream::DEFAULT_PROTOCOL); $resource = fopen($filename, 'w+'); fwrite($resource, 'first'); fwrite($resource, 'second,'); $result = fread($resource, 20); fclose($resource); Stream::unregister(); // remove a StreamWrapper registered.

In this example, PHP will not use the filesystem to perform these f* functions., (*8)

The Versions

20/08 2017

dev-master

9999999-dev

A Virtual Stream Wrapper

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Pedro Ribeiro da Silva Neto

mock file stream stream wrapper pcelta

20/08 2017

dev-composer-test

dev-composer-test

A Virtual Stream Wrapper

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Pedro Ribeiro da Silva Neto

mock file stream stream wrapper pcelta