{"id":13622587,"url":"https://github.com/fzaninotto/Streamer","last_synced_at":"2025-04-15T09:33:04.317Z","repository":{"id":62508475,"uuid":"4788450","full_name":"fzaninotto/Streamer","owner":"fzaninotto","description":"Object-Oriented API for PHP streams","archived":true,"fork":false,"pushed_at":"2017-01-31T08:20:20.000Z","size":18,"stargazers_count":267,"open_issues_count":4,"forks_count":31,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-08-01T21:54:13.239Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fzaninotto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-25T22:45:18.000Z","updated_at":"2024-02-28T20:13:57.000Z","dependencies_parsed_at":"2022-11-02T12:46:13.297Z","dependency_job_id":null,"html_url":"https://github.com/fzaninotto/Streamer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzaninotto%2FStreamer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzaninotto%2FStreamer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzaninotto%2FStreamer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fzaninotto%2FStreamer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fzaninotto","download_url":"https://codeload.github.com/fzaninotto/Streamer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223668236,"owners_count":17182893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T21:01:21.367Z","updated_at":"2024-11-08T10:30:33.934Z","avatar_url":"https://github.com/fzaninotto.png","language":"PHP","readme":"# Streamer\n\nStreamer is an Object-Oriented API for PHP streams.\n\n## Why should I use Streams?\n\nA stream is a flow of bytes from one container to the other. You already use streams a lot in PHP, for instance each time you load a file into memory (`file_get_contents()`). You should explicitly use streams each time that:\n\n* You need to access data from a container, but you don't know the size of this container (e.g. reading from STDIN, or a web service using streaming)\n* You need to start processing data from a container before the whole transfer is finished (e.g. start zipping a file before it's all in memory)\n* You need to save time and memory\n\n## What is Streamer?\n\nPHP has a very elaborate stream API ; unfortunately, it uses functions for most stream operations (except for wrappers - go figure). Streamer is a generic library focusing on offering an object-oriented API to streams, and only that.\n\n## Installation\n\nStreamer is published on [packagist.org](http://packagist.org/packages/fzaninotto/Streamer), so you can add it to your `composer.json` file for an easy installation:\n\n```sh\ncomposer require fzaninotto/Streamer\n```\n\nor\n\n```json\n{\n    \"require\": {\n        \"fzaninotto/Streamer\": \"0.0.1\"\n    }\n}\n```\n\n## Example\n\n```php\n\u003c?php\nuse Streamer\\Stream,\n\tStreamer\\FileStream,\n\tStreamer\\NetworkStream;\n\n// basic usage\n$stream = new Stream(fopen('smiley.png', 'r'));\n$image = '';\nwhile (!$stream-\u003eisEOF()) {\n  $image .= $stream-\u003eread();\n}\n\n// pipe dreams!\n$stream1 = new Stream(fopen('smiley.png', 'r'));\n$stream2 = new Stream(fopen('tmp.png', 'w'));\n// copy the contents from the first stream to the second one\n$stream1-\u003epipe($stream2);\n\n// factory\n$fileStream = FileStream::create('smiley.png', 'r');\nprint_r($fileStream);\n\n$networkStream = NetworkStream::create('tcp://www.google.com:80');\nprint_r($networkStream);\n\n```\n\n### Credits\n\nStreamer is heavily inspired by other Stream class implementations:\n\n* [Guzzle](https://github.com/guzzle/streams/blob/ce5a645ee89ea0914db1f601b917b8bf211e3630/src/Stream.php)\n* [Joomla's Filesystem Stream](http://api.joomla.org/__filesource/fsource_Joomla-Platform_FileSystem--_librariesjoomlafilesystemstream.php.html)\n* [Node.Js Stream API](http://nodejs.org/api/stream.html)\n","funding_links":[],"categories":["流","流 Streams","Table of Contents","PHP","Streams","目录","流( Stream )"],"sub_categories":["Streams","流 Streams"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzaninotto%2FStreamer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffzaninotto%2FStreamer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffzaninotto%2FStreamer/lists"}