All Projects → bertptrs → Phpstreams

bertptrs / Phpstreams

Licence: mit
A streams library for PHP inspired by the Java 8 Streams API.

Labels

Projects that are alternatives of or similar to Phpstreams

Stream Go2
GetStream.io Go client
Stars: ✭ 67 (-22.99%)
Mutual labels:  stream
Iter
Simple iterator abstract datatype, intended to iterate efficiently on collections while performing some transformations.
Stars: ✭ 71 (-18.39%)
Mutual labels:  stream
Opus Stream Decoder
Instantly decode Ogg Opus audio streams in chunks with JavaScript & WebAssembly (Wasm)
Stars: ✭ 80 (-8.05%)
Mutual labels:  stream
Freeiptv
FreeIPTV • Watch Free IPTV World Wide
Stars: ✭ 68 (-21.84%)
Mutual labels:  stream
Rxjavajdk8interop
RxJava 2/3 interop library for supporting Java 8 features such as Optional, Stream and CompletableFuture [discontinued]
Stars: ✭ 70 (-19.54%)
Mutual labels:  stream
Athenax
SQL-based streaming analytics platform at scale
Stars: ✭ 1,178 (+1254.02%)
Mutual labels:  stream
Framework
Asynchronous & Fault-tolerant PHP Framework for Distributed Applications.
Stars: ✭ 1,125 (+1193.1%)
Mutual labels:  stream
Iostreams
IOStreams is an incredibly powerful streaming library that makes changes to file formats, compression, encryption, or storage mechanism transparent to the application.
Stars: ✭ 84 (-3.45%)
Mutual labels:  stream
Nodestream
Storage-agnostic streaming library for binary data transfers
Stars: ✭ 70 (-19.54%)
Mutual labels:  stream
Node Promisepipe
Safely pipe node.js streams while capturing all errors to a single promise
Stars: ✭ 79 (-9.2%)
Mutual labels:  stream
Fast Dat Parser
Superfast blockchain parser for stats
Stars: ✭ 68 (-21.84%)
Mutual labels:  stream
Target Postgres
A Singer.io Target for Postgres
Stars: ✭ 70 (-19.54%)
Mutual labels:  stream
Stream
流媒体解锁后端
Stars: ✭ 71 (-18.39%)
Mutual labels:  stream
Activity
⚡️ Activity app for Nextcloud
Stars: ✭ 67 (-22.99%)
Mutual labels:  stream
Optbinning
Optimal binning: monotonic binning with constraints. Support batch & stream optimal binning
Stars: ✭ 79 (-9.2%)
Mutual labels:  stream
Ksql Fork With Deep Learning Function
Deep Learning UDF for KSQL, the Streaming SQL Engine for Apache Kafka with Elasticsearch Sink Example
Stars: ✭ 64 (-26.44%)
Mutual labels:  stream
Sec Api
sec.gov EDGAR API | search & filter SEC filings | over 150 form types supported | 10-Q, 10-K, 8, 4, 13, S-11, ... | insider trading
Stars: ✭ 71 (-18.39%)
Mutual labels:  stream
Advanced Php
最近打算写一些php一些偏微妙的教程,比如关于多进程、socket等相关,都是自己的一些感悟心得
Stars: ✭ 1,271 (+1360.92%)
Mutual labels:  stream
Cloud Media Scripts
Upload and stream media from the cloud with or without encryption. Cache all new and recently streamed media locally to access quickly and reduce API calls
Stars: ✭ 84 (-3.45%)
Mutual labels:  stream
String To Stream
Convert a string into a stream (streams2)
Stars: ✭ 75 (-13.79%)
Mutual labels:  stream

PHPStreams

Latest Stable Version Total Downloads License Build Status

A partial implementation of the Java 8 Streams API in PHP. PHPStreams can use your generators, your arrays and really anything that is Iterable and convert modify it like you're used to using Java Streams!

Using streams and generators, you can easily sort through large amounts of data without having to have it all in memory or in scope. Streams also make it easier to structure your code, by (more or less) enforcing single resposibility.

The library is compatible with PHP 5.5.9 and up.

Installation

PHPStreams can be installed using Composer. Just run composer require bertptrs/phpstreams in your project root!

Usage

Using streams is easy. Say, we want the first 7 odd numbers in the Fibonacci sequence. To do this using Streams, we do the following:

// Define a generator for Fibonacci numbers
function fibonacci()
{
    yield 0;
    yield 1;

    $prev = 0;
    $cur = 1;

    while (true) {
        yield ($new = $cur + $prev);
        $prev = $cur;
        $cur = $new;
    }
};

// Define a predicate that checks for odd numbers
$isOdd = function($num) {
    return $num % 2 == 1;
};

// Create our stream.
$stream = new phpstreams\Stream(fibonacci());

// Finally, use these to create our result.
$oddFibo = $stream->filter($isOdd)  // Keep only the odd numbers
    ->limit(8)                      // Limit our results
    ->toArray(false);               // Convert to array, discarding keys

Documentation

Documentation is mostly done using PHPDoc. I do intend to write actual documtation if there is any interest.

Contributing

I welcome contributions and pull requests. Please note that I do follow PSR-2 (and PSR-4 for autoloading). Also, please submit unit tests with your work.

GrumPHP enforces at least part of the coding standard, but do make an effort to structure your contributions nicely.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].