PHPackages                             dhii/io-resource-interface - 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. dhii/io-resource-interface

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

dhii/io-resource-interface
==========================

Interfaces for resource interoperability

09PHP

Since Aug 27Pushed 8y ago2 watchersCompare

[ Source](https://github.com/Dhii/io-resource-interface)[ Packagist](https://packagist.org/packages/dhii/io-resource-interface)[ RSS](/packages/dhii-io-resource-interface/feed)WikiDiscussions develop Synced 2w ago

READMEChangelogDependenciesVersions (3)Used By (0)

Dhii - IO - Resource - Interface
================================

[](#dhii---io---resource---interface)

[![Build Status](https://camo.githubusercontent.com/f9cd1b4ab2ca54eb418417b01b5f0e86ea33ee9ae60c4ba9b9c7a233f92eb782/68747470733a2f2f7472617669732d63692e6f72672f446869692f696f2d7265736f757263652d696e746572666163652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Dhii/io-resource-interface)[![Code Climate](https://camo.githubusercontent.com/11108c5bba07a42fd8d62e1e4b198a7b4db5e43247d4fc144534b1db6a9b2181/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f446869692f696f2d7265736f757263652d696e746572666163652f6261646765732f6770612e737667)](https://codeclimate.com/github/Dhii/io-resource-interface)[![Test Coverage](https://camo.githubusercontent.com/3bc962177d86c6a891ae73a2975c5a74e1870b42919ae21b13925ddf80a921e0/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f446869692f696f2d7265736f757263652d696e746572666163652f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/Dhii/io-resource-interface/coverage)[![Latest Stable Version](https://camo.githubusercontent.com/92cec66266ab9e07c30380310e299047ed8e07c3a974b7484f285cf05758363a/68747470733a2f2f706f7365722e707567782e6f72672f646869692f696f2d7265736f757263652d696e746572666163652f76657273696f6e)](https://packagist.org/packages/dhii/io-resource-interface)[![This package complies with Dhii standards](https://camo.githubusercontent.com/44bbe8c7678c1784cfc53cabce5d3e32fc22a840453c5ed9c08601522fe7c213/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446869692d436f6d706c69616e742d677265656e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/Dhii/dhii)

Interfaces for resource interoperability.

Details
-------

[](#details)

This package aims to accomplish these main goals:

1. Provide a standard for stream interoperability that is separate from [PSR-7](http://www.php-fig.org/psr/psr-7/). The PSR-7 standard is large and unwieldly, and we felt like streaming is a concept separate from HTTP messaging, because many consumers of input and output do not care or need to care where the input or output points to. For example, `stdout` has nothing to do with HTTP or networking per se. Instead, interoperable streams should be used to write or read data regardless of the source or target.
2. Restore [ISP](https://en.wikipedia.org/wiki/Interface_segregation_principle) for stream interop standard. The PSR-7 standard aggregates many functions of streams in one large interface. This is non-[SOLID](https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)), because a consumer may want to only write to a stream, and the stream may not even be readable; and vice-versa. At the same time, with ISP, it is possible to detect abilities of a stream using the [`instanceof`](php.net/manual/en/internals2.opcodes.instanceof.php) operator, which is clean and we feel that it is more correct.
3. Provide compatibility with existing [Dhii](https://github.com/Dhii/dhii) standards. The ability of a stream to be converted to string is therefore formalized, meaning that a readable stream can be provided wherever a [stringable](https://github.com/Dhii/stringable-interface) value is expected, which is very convenient.
4. Abstract the concept of "resource". All streams are resources in the general meaning, but not all resources are streams. A resource object can allow writing to a variable in memory, not only to an actual stream or file. A database connection could also be a resource, and one could execute queries by writing to such a resource.

### Compatibility

[](#compatibility)

Interfaces in this package are mostly compatible with the [`StreamInterface`](https://github.com/php-fig/http-message/blob/master/src/StreamInterface.php)interface defined in PSR-7, albeit splitting it into more segregated parts. One major difference is that [`ReadableResourceInterface#__toString()`](https://github.com/Dhii/io-resource-interface/blob/task/initial-interfaces/src/ReadableResourceInterface.php#L44) is not expected to seek to the beginning of the resource, but may simply return the remainder of the content. This is mainly because seeking capabilities are separated from reading capabilities. If implementations wish to be compatible with that behaviour of [`StreamInterface#__toString()`](https://github.com/php-fig/http-message/blob/master/src/StreamInterface.php#L28), they are encouraged to detect seek-ability and perform the rewind, if possible.

### Interfaces

[](#interfaces)

- [`ResourceInterface`](src/ResourceInterface.php) - The base interface for all resources. Implies that any resource can determine whether it's open, can be closed explicitly, opened implicitly, and can attempt to determine its size.
- [`ReadableResourceInterface`](src/ReadableResourceInterface.php) - A resource that can be read from. Implies that it is possible to read the whole contents of it, or a part of the contents, and determine whether there is any more data.
- [`WritableResourceInterface`](src/WritableResourceInterface.php) - A resource that can be written to. Implies that it's possible to write a series of bytes to it.
- [`ResourceAwareInterface`](src/ResourceAwareInterface.php) - Something that can have a resource retrieved.
- [`ResourceExceptionInterface`](src/Exception/ResourceExceptionInterface.php) - An exception that is related to a resource.
- [`CouldNotReadExceptionInterface`](src/Exception/CouldNotReadExceptionInterface.php) - An exception that occurs when a readable resource is unable to be read from.
- [`CouldNotWriteExceptionInterface`](src/Exception/CouldNotWriteExceptionInterface.php) - An exception that occurs when a writable resource is unable to be written to.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1894e91b32c9f80d8f30a42d360af6983a507f1cf2c621b7c9a0a0de14e011c5?d=identicon)[XedinUnknown](/maintainers/XedinUnknown)

---

Top Contributors

[![XedinUnknown](https://avatars.githubusercontent.com/u/1428973?v=4)](https://github.com/XedinUnknown "XedinUnknown (26 commits)")

### Embed Badge

![Health badge](/badges/dhii-io-resource-interface/health.svg)

```
[![Health](https://phpackages.com/badges/dhii-io-resource-interface/health.svg)](https://phpackages.com/packages/dhii-io-resource-interface)
```

###  Alternatives

[drupal/core-composer-scaffold

A flexible Composer project scaffold builder.

5344.1M546](/packages/drupal-core-composer-scaffold)[sebastianfeldmann/git

PHP git wrapper

497.8M21](/packages/sebastianfeldmann-git)[integer-net/magento2-sansec-watch

Sansec Watch integration for Magento 2

40190.3k](/packages/integer-net-magento2-sansec-watch)

PHPackages © 2026

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