{"id":15690317,"url":"https://github.com/serafimarts/stream","last_synced_at":"2025-05-07T23:37:08.028Z","repository":{"id":62542318,"uuid":"163760361","full_name":"SerafimArts/Stream","owner":"SerafimArts","description":"PHP realtime source streaming library","archived":false,"fork":false,"pushed_at":"2021-05-27T02:50:12.000Z","size":97,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-26T05:41:31.796Z","etag":null,"topics":["hooks","patching","realtime","restream","sources","streaming","transpiling","wrapper"],"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/SerafimArts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-01T19:14:46.000Z","updated_at":"2024-07-28T05:46:46.000Z","dependencies_parsed_at":"2022-11-02T15:46:43.261Z","dependency_job_id":null,"html_url":"https://github.com/SerafimArts/Stream","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2FStream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2FStream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2FStream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2FStream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SerafimArts","download_url":"https://codeload.github.com/SerafimArts/Stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243042922,"owners_count":20226722,"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":["hooks","patching","realtime","restream","sources","streaming","transpiling","wrapper"],"created_at":"2024-10-03T18:08:43.451Z","updated_at":"2025-03-11T13:32:01.969Z","avatar_url":"https://github.com/SerafimArts.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"./resources/logo.png\" width=\"128\" alt=\"Stream\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://travis-ci.org/SerafimArts/Stream\"\u003e\u003cimg src=\"https://travis-ci.org/SerafimArts/Stream.svg?branch=master\" alt=\"Travis CI\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/SerafimArts/Stream/?branch=master\"\u003e\u003cimg src=\"https://scrutinizer-ci.com/g/SerafimArts/Stream/badges/coverage.png?b=master\" alt=\"Coverage\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/SerafimArts/Stream/?branch=master\"\u003e\u003cimg src=\"https://scrutinizer-ci.com/g/SerafimArts/Stream/badges/quality-score.png?b=master\" alt=\"Scrutinizer CI\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/stream\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/stream/version\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/stream\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/stream/v/unstable\" alt=\"Latest Unstable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://raw.githubusercontent.com/serafim/stream/master/LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\" alt=\"License MIT\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/stream\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/stream/downloads\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Sources Streaming Package\n\n## Installation\n\n`composer require serafim/stream`\n\n[Package on packagist.org](https://packagist.org/packages/serafim/stream)\n\n## Introduction\n\nStream package provides the ability to override the data contained within the \nfiles in real time.\n\n## Protocol Streaming\n\n```php\n\u003c?php\n\nuse Serafim\\Stream\\Stream;\n\nStream::create('some')\n    -\u003etryRead(function (string $pathname): string {\n        return $pathname;\n    });\n\necho \\file_get_contents('some://example'); // string(7) \"example\"\n```\n\n```php\n\u003c?php\n\nuse Serafim\\Stream\\Stream;\n\nStream::create('four')\n    -\u003eonRead(function (string $sources): string {\n        return $sources . \"\\n\" . 'return 4;';\n    });\n\necho require 'four://example.php'; // int(1) \"4\"\n```\n\n## Composer\n\n```php\n\u003c?php\nuse Serafim\\Stream\\ClassLoader;\n\n$composer = require __DIR__ . '/vendor/autoload.php';\n\n$loader = new ClassLoader($composer);\n$loader-\u003ewhen\n    // The stream will be triggered only on those files\n    // whose namespace starts with \"App\"\n    -\u003enamespace('App')\n    -\u003ethen(function (string $sources): string {\n        \\var_dump(42);\n        \n        return $sources;\n    });\n\n// When loading this class, var_dump(42) will be displayed.\nnew App\\Example();\n```\n\n## Composer Filters\n\nEach filter starts with calling the `$loader-\u003ewhen` method.\n\n### Filter `where`\n\nIt works when the result of an anonymous function passed to the method `where` \nreturns the `true`.\n\n```php\n$loader-\u003ewhen-\u003ewhere(function (string $class, string $pathname): bool {\n    return $class === 'User';\n});\n\n$user = new User();\n```\n\n### Filter `not`\n\nIt works when the result of an anonymous function passed to the method `not` \nreturns the `false`.\n\n```php\n$loader-\u003ewhen-\u003enot(function (string $class, string $pathname): bool {\n    return $class !== 'User';\n});\n\n$user = new User();\n```\n\n### Filter `every`\n\nWorks when each rule applied inside an anonymous function returns\na positive result.\n\n```php\nuse Serafim\\Stream\\Filter\\Conjunction;\n\n$loader-\u003ewhen-\u003eevery(function (Conjunction $fn) {\n    $fn-\u003ewhere(...);\n    // AND\n    $fn-\u003ewhere(...);\n});\n```\n\n### Filter `any`\n\nWorks when any (one of) rule applied inside an anonymous function returns\na positive result.\n\n```php\nuse Serafim\\Stream\\Filter\\Disjunction;\n\n$loader-\u003ewhen-\u003eany(function (Disjunction $fn) {\n    $fn-\u003ewhere(...); \n    // OR\n    $fn-\u003ewhere(...);\n});\n```\n\n### Filter `fqn`\n\nWorks in the case when the fqn (Fully qualified name) corresponds \nto the specified.\n\n```php\n$loader-\u003ewhen-\u003efqn('App\\\\User');\n\nnew App\\User(); // Stream works\nnew Some\\App\\User(); // Stream does not work\n```\n\n### Filter `className`\n\nWorks in the case when the class name corresponds \nto the specified.\n\n```php\n$loader-\u003ewhen-\u003eclassName('User');\n\nnew App\\User(); // OK\nnew Any\\User(); // OK\n```\n\n### Filter `namespace`\n\nWorks in the case when the namespace corresponds \nto the specified.\n\n```php\n$loader-\u003ewhen-\u003eclassName('App');\n\nnew App\\User(); // OK\nnew App\\Message(); // OK\n```\n\n### Filter `fileName`\n\nWorks in the case when the file name corresponds \nto the specified.\n\n```php\n$loader-\u003ewhen-\u003efileName('App');\n\nnew App(); // The stream is triggered if the file name matches the class name.\n```\n\n### Filter `pathNameMatches`\n\nThe stream is triggered if the path matches the regular expression.\n\n```php\n$loader-\u003ewhen-\u003epathNameMatches('Models/.*');\n```\n\n### Filter `fileNameMatches`\n\nThe stream is triggered if the file name matches the regular expression.\n\n```php\n$loader-\u003ewhen-\u003efileNameMatches('\\w+Interface');\n```\n\n### Filter `classNameMatches`\n\nThe stream is triggered if the class name matches the regular expression.\n\n```php\n$loader-\u003ewhen-\u003eclassNameMatches('\\w+Interface');\n```\n\n### Filter `fqnMatches`\n\nThe stream is triggered if the fqn (Fully qualified name) matches the regular expression.\n\n```php\n$loader-\u003ewhen-\u003efqnMatches('App\\\\.*?\\\\\\w+Interface');\n```\n\n### Filter `withVendors`\n\nThe stream is triggered if the file is loaded from the vendor \ndirectory (by default, all vendor files are ignored)\n\n```php\n$loader-\u003ewhen-\u003ewithVendors();\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimarts%2Fstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserafimarts%2Fstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimarts%2Fstream/lists"}