Download the PHP package jstewmc/stream without Composer

On this page you can find all versions of the php package jstewmc/stream. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package stream

CircleCI codecov

Stream

A multi-byte-safe stream for reading very large files (or strings) character-by-character.

Reading very large files or strings into PHP's memory and exploding them for character-by-character processing - like parsing or lexing - can quickly overrun your process memory.

This library streams the characters of very large text files in an easy, multi-byte, memory-safe manner:

The (trivial) example above would produce the following output:

In the background, this library uses jstewmc/chunker to chunk very large text files or strings in a multi-byte, low-memory manner and moves between chunks as necessary.

Installation

This library requires PHP 7.4+.

It is multi-platform, and we strive to make it run equally well on Windows, Linux, and OSX.

It should be installed via Composer. To do so, add the following line to the require section of your composer.json file, and run composer update:

Usage

Instantiating a stream

A stream can be instantiated as Text or File:

By default, a stream uses the environment's character encoding and a chunk size of around 8kb. If you need more control, you can instantiate a stream using a Chunker instance, instead of a string:

Navigating a stream

Once a stream has been instantiated, you can get the stream's current, next, and previous characters using the getCurrentCharacter(), getNextCharacter(), and getPreviousCharacter() methods, respectively (these methods are aliased as current(), next(), and previous(), respectively, and they will return false if the character does not exist):

These methods will typically be combined in a while loop like so:

Keep in mind, these methods are idempotent and repeatable. For example, you can call next() multiple times at the end of the stream without proceeding past the end of the stream, and you can call previous() from the end of the stream to navigate in the opposite direction.

Peaking ahead

You can use the peek() method to look ahead to the next n characters without updating the internal index:

Testing the content

You can use the isOn() method to test whether or not the stream is on a string or includes one of an array of strings:

You can use the isOnRegex() method to test whether or not a number of characters match the given regular expression (rather than attempt to detect the number of characters in the regular expression, which would be very difficult, the number of characters to search is the second argument):

Resetting the stream

If you need to, you can reset the stream's internal pointer:

License

This library is released under the MIT license.

Contributing

Contributions are welcome!

Here are the steps to get started:


All versions of stream with dependencies

PHP Build Version
Package Version
Requires ext-mbstring Version *
php Version ^7.4 || ^8.0
jstewmc/chunker Version ^0.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jstewmc/stream contains the following files

Loading the files please wait ....