PHPackages                             ulovdomov/php-stream - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ulovdomov/php-stream

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ulovdomov/php-stream
====================

Php Stream

v1.0.5(5mo ago)09.2k—0%MITPHPPHP &gt;=8.0 &lt;8.6CI passing

Since May 24Pushed 5mo agoCompare

[ Source](https://github.com/ulovdomov/php-stream)[ Packagist](https://packagist.org/packages/ulovdomov/php-stream)[ RSS](/packages/ulovdomov-php-stream/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (5)Versions (7)Used By (0)

Php Stream
==========

[](#php-stream)

This package provides a PSR-7-compatible `StreamInterface` implementation, along with an extended `UlovDomov\Stream\FileStream` class that adds more.

Installation
------------

[](#installation)

Run:

```
composer require ulovdomov/php-stream
```

Usage
-----

[](#usage)

### Create `UlovDomov\Stream\FileStream`

[](#create-ulovdomovstreamfilestream)

You can create stream from:

- `resource`
- `string`
- `int`
- `float`
- `bool`
- `\Psr\Http\Message\StreamInterface`
- `callable`
- `\Iterator`
- `null`

```
$stream = \UlovDomov\Stream\FileStream::create('my stream content');
```

For `file path`:

```
// stream for reading
$stream = \UlovDomov\Stream\FileStream::createForPath(__DIR__ . '/file.pdf');

// stream for writing
$stream = \UlovDomov\Stream\FileStream::createForPath(__DIR__ . '/file.pdf', 'w');
```

Additional features
-------------------

[](#additional-features)

```
/** @var UlovDomov\Stream\FileStream $stream */

// get mime type
$stream->getMimeType(); // string: text/plain

// get file extension (can return null for application/octet-stream or unknown mimetype)
$stream->getExtension(); // string: txt

// save content as file
$stream->saveAs(__DIR__ . '/my-new-file.jpg');
```

Utils
-----

[](#utils)

### Method `tryFopen`

[](#method-tryfopen)

Replacement for `fopen`, it returns a resource; throws a `StreamException` on error.

```
/** @var resource $file */
$file = \UlovDomov\Stream\Utils::tryFopen(__DIR__ . '/my-file.pdf');
```

### Method `mimetypeToExtension`

[](#method-mimetypetoextension)

Get file extension. Can return null for `application/octet-stream` or not implemented mimetype.

```
\UlovDomov\Stream\Utils::mimetypeToExtension('application/pdf');
// "pdf"
```

### Method `isOctetStream`

[](#method-isoctetstream)

Get `true` if mimetype is `application/octet-stream`.

```
\UlovDomov\Stream\Utils::isOctetStream('application/octet-stream');
// true

\UlovDomov\Stream\Utils::isOctetStream('text/json');
// false
```

Development
-----------

[](#development)

### First setup

[](#first-setup)

1. Run for initialization

```
make init
```

2. Run composer install

```
make composer
```

Use tasks in Makefile:

- To log into container

```
make docker
```

- To run code sniffer fix

```
make cs-fix
```

- To run PhpStan

```
make phpstan
```

- To run tests

```
make phpunit
```

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance72

Regular maintenance activity

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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 ~38 days

Recently: every ~48 days

Total

6

Last Release

157d ago

PHP version history (3 changes)v1.0.0PHP &gt;=8.1 &lt;8.5

v1.0.3PHP &gt;=8.0 &lt;8.5

v1.0.5PHP &gt;=8.0 &lt;8.6

### Community

Maintainers

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

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

---

Top Contributors

[![mesour](https://avatars.githubusercontent.com/u/1161897?v=4)](https://github.com/mesour "mesour (13 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ulovdomov-php-stream/health.svg)

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

###  Alternatives

[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M78](/packages/google-cloud-core)[aimeos/aimeos-base

Aimeos base layer for abstracting from host environments

2.1k134.0k1](/packages/aimeos-aimeos-base)[phpgt/dom

Modern DOM API.

12412.2M17](/packages/phpgt-dom)[razorpay/ifsc

Razorpay IFSC Codes Library

382201.9k](/packages/razorpay-ifsc)[anthropic-ai/sdk

Anthropic PHP SDK

129134.7k5](/packages/anthropic-ai-sdk)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73142.3k25](/packages/jaxon-php-jaxon-core)

PHPackages © 2026

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