PHPackages                             symlex/stream-sampler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. symlex/stream-sampler

ActiveProject[CLI &amp; Console](/categories/cli)

symlex/stream-sampler
=====================

Example PHP command-line application based on Symlex Core

v2.0.1(7y ago)1239MITPHPPHP &gt;=7.1

Since Oct 17Pushed 7y agoCompare

[ Source](https://github.com/symlex/stream-sampler)[ Packagist](https://packagist.org/packages/symlex/stream-sampler)[ Docs](https://github.com/symlex/stream-sampler)[ RSS](/packages/symlex-stream-sampler/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (4)Versions (8)Used By (0)

Example CLI app based on [Symlex Core](https://github.com/symlex/symlex-core)
=============================================================================

[](#example-cli-app-based-on-symlex-core)

[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/f9715af16595628c66d8d8335b3a763c2106ad71769900d5d2b67dafb04b8764/68747470733a2f2f7472617669732d63692e6f72672f73796d6c65782f73747265616d2d73616d706c65722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/symlex/stream-sampler)[![Documentation](https://camo.githubusercontent.com/84e7e669c9ae017b0fad97fbe04fe187e788bc569eabc772c41e9a2ec33e2708/68747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f73796d6c65782d646f63732f62616467652f3f76657273696f6e3d6c6174657374267374796c653d666c6174)](https://docs.symlex.org/en/latest/)[![Community Chat](https://camo.githubusercontent.com/bf8ea831b14602e140cc1b36ea5c1979dc72055a61475a804d68ca875bdaa52d/68747470733a2f2f6261646765732e6769747465722e696d2f73796d6c65782f636f6d6d756e6974792e706e67)](https://gitter.im/symlex/community)

This application is compatible with PHP 7.1+ with the *curl* extension enabled.

Clone this repository to a local directory and run composer:

```
git clone https://github.com/symlex/stream-sampler.git
cd stream-sampler
composer update

```

Alternatively you can run composer to create a new project from the latest stable release and fetch external dependencies:

```
composer create-project symlex/stream-sampler my-stream-sampler

```

Composer will ask for config values to generate `app/config/parameters.yml` for you.

YAML files located in `app/config` configure the app based on parameters and services. The main config file is `app/config/console.yml`.

What does a stream sampler do?
------------------------------

[](#what-does-a-stream-sampler-do)

It randomly returns a representative sample of *k* items from a stream of values with unknown and possibly very large length. The implementation relies on Algorithm R, which has a complexity of O(N). See [https://en.wikipedia.org/wiki/Reservoir\_sampling](https://en.wikipedia.org/wiki/Reservoir_sampling)

Usage
-----

[](#usage)

```
app/console sample [options]

Options:
  -i, --input[=INPUT]   Input source (stdin, random.org, internal) [default: "stdin"]
  -s, --size[=SIZE]     Sample size (1 - 2000) [default: 5]
  -V, --version         Display the application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output

```

*Note: If you're using random.org or the internal random character source, input data size will be 10 times the sample size. The maximum sample size is 2000.*

Examples
--------

[](#examples)

```
# app/console sample -i internal -s 10
vgB4xtQTF3

# app/console sample -i random.org -s 8
FcojkJX1

# app/console sample < LICENSE
TegcI

# echo 'Pe7emsXm0EHfwAVx' | app/console sample
Xe7es

```

Tests
-----

[](#tests)

Stream Sampler comes with a pre-configured PHPUnit environment that automatically executes tests found in `src/`:

```
PHPUnit 7.5.1 by Sebastian Bergmann and contributors.

.......                                         7 / 7 (100%)

Time: 431 ms, Memory: 8.00MB

OK (7 tests, 16892 assertions)

```

See also:  (self-initializing database fixtures and dependency injection for unit tests)

Similar work
------------

[](#similar-work)

-  (PHP)
-  (PHP)
-  (JavaScript)
-  (JavaScript)

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~196 days

Recently: every ~294 days

Total

7

Last Release

2687d ago

Major Versions

v1.0.4 → v2.0.02019-01-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/f932b09a688c990f2869e72c771bf0eeb009b264a47a1cf78d54c13f566511da?d=identicon)[lastzero](/maintainers/lastzero)

---

Top Contributors

[![lastzero](https://avatars.githubusercontent.com/u/301686?v=4)](https://github.com/lastzero "lastzero (29 commits)")

---

Tags

example-projectphpphp-frameworkstream-samplersymfonysymfony-console

### Embed Badge

![Health badge](/badges/symlex-stream-sampler/health.svg)

```
[![Health](https://phpackages.com/badges/symlex-stream-sampler/health.svg)](https://phpackages.com/packages/symlex-stream-sampler)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[chi-teck/drupal-code-generator

Drupal code generator

26947.8M5](/packages/chi-teck-drupal-code-generator)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
